List of usage examples for javax.swing JComponent setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java
/** * @param fi//from ww w . ja v a 2s.c o m * @return */ protected FormPanelInfo createPanel(final FormInfo formInfo) { CellConstraints cc = new CellConstraints(); JPanel panel = new JPanel(null); int maxWidth = 0; int maxHeight = 0; int maxCellWidth = 0; int maxCellHeight = 0; for (FormFieldInfo fi : formInfo.getFields()) { System.out.println(fi.getCaption()); boolean addLbl = true; JComponent comp = null; switch (fi.getControlTypeNum()) { case 4: comp = createComboBox(); // 'Picklist' break; case 5: { JComboBox cbx = createComboBox(); //new ValComboBoxFromQuery(DBTableIdMgr.getInstance().getInfoById(1), "catalogNumber","CatalogNumber","CatalogNumber"," "," "," "," "," ",ValComboBoxFromQuery.CREATE_ALL);// 'QueryCombo' cbx.setEditable(true); cbx.getEditor().setItem(fi.getCaption()); JPanel cPanel = new JPanel(new BorderLayout()); cPanel.add(cbx, BorderLayout.CENTER); cPanel.add(createElipseBtn(), BorderLayout.EAST); comp = cPanel; addLbl = false; break; } case 7: { String uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", fi.getParent().getFormType()); FormInfo subForm = formHash.get(uniqueKey); if (subForm == null) { uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", null); subForm = formHash.get(uniqueKey); } if (subForm != null) { Vector<String> headers = new Vector<String>(); for (int i = 0; i < subForm.getFields().size(); i++) { headers.add(subForm.getFields().get(i).getCaption()); } JPanel p = new JPanel(new BorderLayout()); p.add(UIHelper.createScrollPane(new JTable(new Vector<Vector<Object>>(), headers)), BorderLayout.CENTER); // 'Grid' comp = p; addLbl = false; } break; } case 8: // 'EmbeddedForm' { String uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", fi.getParent().getFormType()); FormInfo subForm = formHash.get(uniqueKey); if (subForm == null) { uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", null); subForm = formHash.get(uniqueKey); } comp = (subForm != null ? createPanel(subForm).getPanel() : new JPanel()); addLbl = fi.getControlTypeNum() != 8; break; } case 9: { comp = createElipseBtn(); break; } case 20: comp = createScrollPane(createTextArea()); // 'Memo' break; case 21: comp = null;//createComboBox(); // 'MenuItem' break; case 46: comp = createTextField("URL"); // 'URL' break; default: if (fi.getDataTypeNum() == 4) { comp = createCheckBox(" "); } else { comp = createTextField(); } } // switch if (comp != null) { String toolTip = "Field: " + fi.getSp5FieldName() + (StringUtils.isNotEmpty(fi.getSp6FieldName()) && fi.getSp6FieldName().equalsIgnoreCase(fi.getSp5FieldName()) ? " Sp6: " + fi.getSp6FieldName() : ""); comp.setToolTipText(toolTip); PanelBuilder pb = new PanelBuilder(new FormLayout("p,1px,f:p:g", "f:p:g,p,f:p:g")); pb.getPanel().setToolTipText(toolTip); pb.getPanel().setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); if (addLbl) { pb.add(createLabel(fi.getCaption()), cc.xy(1, 2)); } pb.add(comp, cc.xy(3, 2)); panel.add(pb.getPanel()); maxWidth = Math.max(maxWidth, fi.getLeft() + fi.getWidth()); maxHeight = Math.max(maxHeight, fi.getTop() + fi.getHeight()); maxCellWidth = Math.max(maxWidth, fi.getCellX() + fi.getCellWidth()); maxCellHeight = Math.max(maxHeight, fi.getCellY() + fi.getCellHeight()); boolean newWay = false; if (newWay) { Rectangle r = fi.getBoundsFromCellDim(); pb.getPanel().setLocation(r.x, r.y); pb.getPanel().setSize(r.width, r.height); } else { pb.getPanel().setLocation(fi.getLeft(), fi.getTop()); pb.getPanel().setSize(fi.getWidth(), fi.getHeight()); } System.out.println("MaxW: " + maxWidth + " " + maxCellWidth); System.out.println("MaxH: " + maxHeight + " " + maxCellHeight); } } boolean newWay = false; if (newWay) { int cw = FormFieldInfo.getSegWidth(); panel.setPreferredSize(new Dimension(maxCellWidth * cw, maxCellHeight * cw)); panel.setSize(new Dimension(maxCellWidth * cw, maxCellHeight * cw)); } else { panel.setPreferredSize(new Dimension(maxWidth, maxHeight)); panel.setSize(new Dimension(maxWidth, maxHeight)); } System.out.println("MaxW: " + maxWidth + " " + maxCellWidth); System.out.println("MaxH: " + maxHeight + " " + maxCellHeight); return new FormPanelInfo(formInfo.getTitle(), panel, maxWidth, maxHeight); }
From source file:app.RunApp.java
/** * Set help for metrics table//from ww w. j av a 2s . c o m * * @param jtable Table * @return Table with help */ public JTable setMetricsHelp(JTable jtable) { jtable = new JTable(jtable.getModel()) { @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (c instanceof JComponent) { JComponent jc = (JComponent) c; jc.setToolTipText(MetricUtils.getMetricTooltip(getValueAt(row, 0).toString())); } return c; } }; return jtable; }
From source file:app.RunApp.java
/** * Set help for Chi and Phi //ww w. ja v a2 s .c om * * @param jtable Table * @return Table with help */ public JTable setChiPhiTableHelp(JTable jtable) { jtable = new JTable(jtable.getModel()) { @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (c instanceof JComponent) { JComponent jc = (JComponent) c; if (row > column) { jc.setToolTipText("Chi(" + getColumnName(row) + ", " + getColumnName(column) + ")"); } else if (column > row) { jc.setToolTipText("Phi(" + getColumnName(row) + ", " + getColumnName(column) + ")"); } } return c; } }; return jtable; }
From source file:app.RunApp.java
/** * Set help for Co-ocurrence table/*from w w w.j av a2s . c o m*/ * * @param jtable Table * @return Table with help */ public JTable setCoocurrenceTableHelp(JTable jtable) { jtable = new JTable(jtable.getModel()) { @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (c instanceof JComponent) { JComponent jc = (JComponent) c; if (row > column) { jc.setToolTipText("Coocurrence(" + getColumnName(row) + ", " + getColumnName(column) + ")"); } else { jc.setToolTipText(null); } } return c; } }; return jtable; }
From source file:app.RunApp.java
/** * Set help for heatmap table/*www .ja v a2 s. c o m*/ * * @param jtable Table * @return Table with help */ public JTable setHeatmapTableHelp(JTable jtable) { jtable = new JTable(jtable.getModel()) { @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (c instanceof JComponent) { JComponent jc = (JComponent) c; if (column == row) { jc.setToolTipText("P(" + getColumnName(row) + ")"); } else { jc.setToolTipText("P(" + getColumnName(row) + " | " + getColumnName(column) + ")"); } } return c; } }; return jtable; }
From source file:app.RunApp.java
/** * Set help for MVML table//from w w w.j ava2 s . c om * * @param jtable Table * @return Table with help */ public JTable setMVTableHelp(JTable jtable) { jtable = new JTable(jtable.getModel()) { @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (c instanceof JComponent) { JComponent jc = (JComponent) c; switch (column) { case 0: jc.setToolTipText("View name"); break; case 1: jc.setToolTipText("Number of the attributes of the view"); break; case 2: jc.setToolTipText("Labels x Instances x Features"); break; case 3: jc.setToolTipText("Ratio of number of instances to the number of attributes"); break; case 4: jc.setToolTipText("Average gain ratio"); break; default: break; } } return c; } }; return jtable; }
From source file:net.sourceforge.squirrel_sql.fw.gui.debug.DebugEventListener.java
private void setToolTipText(JComponent source, AWTEvent event) { Container parent = source.getParent(); String sourceName = source.getName(); String sourceClassName = source.getClass().toString(); String parentClassName = parent == null ? null : parent.getClass().toString(); StringBuilder toolTipText = new StringBuilder(getEventMessagePrefix(event)); if (source instanceof AbstractButton) { toolTipText.append("Button with parentClass="); toolTipText.append(parentClassName); } else {/*from w w w . j a va2s . c o m*/ if (!StringUtils.isEmpty(sourceName)) { toolTipText.append(sourceName); } else if (!StringUtils.isEmpty(sourceClassName)) { toolTipText.append(sourceClassName); } } source.setToolTipText(toolTipText.toString()); }
From source file:org.isatools.isacreator.gui.DataEntryForm.java
/** * Adds the fields describing a section to a Container (e.g. JPanel, Box, etc.) * * @param containerToAddTo @see JPanel, @see Box, @see Container * @param sectionToAddTo - @see InvestigationFileSection as a reference for where the fields are being added * @param fieldValues - Map of field name to values. * @param referenceObject - A @see DataEntryReferenceObject which gives information about *//*from w w w . j a v a 2 s . co m*/ public void addFieldsToPanel(Container containerToAddTo, InvestigationFileSection sectionToAddTo, OrderedMap<String, String> fieldValues, DataEntryReferenceObject referenceObject) { if (fieldDefinitions == null) { fieldDefinitions = new ListOrderedMap<String, JComponent>(); } Set<String> ontologyFields = referenceObject.getOntologyTerms(sectionToAddTo); Set<String> fieldsToIgnore = referenceObject.getFieldsToIgnore(); for (String fieldName : fieldValues.keySet()) { if (!fieldsToIgnore.contains(fieldName)) { FieldObject fieldDescriptor = referenceObject.getFieldDefinition(fieldName); if (!fieldDescriptor.isHidden()) { String tmpFieldName = fieldName; if (realNamesToAliases.containsKey(fieldName)) { tmpFieldName = realNamesToAliases.get(fieldName); } JPanel fieldPanel = createFieldPanel(1, 2); JLabel fieldLabel = createLabel(tmpFieldName); JComponent textComponent; if (fieldDescriptor.getDatatype() == DataTypes.STRING || fieldDescriptor.getDatatype() == DataTypes.ONTOLOGY_TERM || fieldDescriptor.getDatatype() == DataTypes.DATE) { textComponent = new RoundedJTextField(10); } else if (fieldDescriptor.getDatatype() == DataTypes.LONG_STRING) { textComponent = new JTextArea(); ((JTextArea) textComponent).setSelectionColor(UIHelper.LIGHT_GREEN_COLOR); ((JTextArea) textComponent).setSelectedTextColor(UIHelper.BG_COLOR); ((JTextArea) textComponent).setWrapStyleWord(true); ((JTextArea) textComponent).setLineWrap(true); textComponent.setBackground(UIHelper.BG_COLOR); textComponent.setBorder(UIHelper.GREEN_ROUNDED_BORDER); } else if (fieldDescriptor.getDatatype() == DataTypes.LIST) { textComponent = new JComboBox(fieldDescriptor.getFieldList()); } else { textComponent = new RoundedJTextField(10); } if (textComponent instanceof JTextArea || textComponent instanceof JTextComponent) { ((JTextComponent) textComponent) .setText(fieldValues.get(fieldName).equals("") ? fieldDescriptor.getDefaultVal() : fieldValues.get(fieldName)); } textComponent.setToolTipText(fieldDescriptor.getDescription()); UIHelper.renderComponent(textComponent, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); fieldPanel.add(fieldLabel); if (textComponent instanceof JTextArea) { JScrollPane invDescScroll = new JScrollPane(textComponent, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); invDescScroll.setPreferredSize(new Dimension(200, 75)); invDescScroll.getViewport().setBackground(UIHelper.BG_COLOR); ((JTextArea) textComponent).getDocument().addDocumentListener(new DocumentChangeListener()); IAppWidgetFactory.makeIAppScrollPane(invDescScroll); fieldPanel.add( UIHelper.createTextEditEnableJTextArea(invDescScroll, (JTextArea) textComponent)); } else if (textComponent instanceof JTextComponent) { if (fieldDescriptor.getDatatype() == DataTypes.ONTOLOGY_TERM || ontologyFields.contains(fieldName)) { fieldPanel.add(createOntologyDropDown(fieldName, (JTextComponent) textComponent, true, false, fieldDescriptor.getRecommmendedOntologySource())); } else if (fieldDescriptor.getDatatype() == DataTypes.DATE) { fieldPanel.add(createDateDropDown((JTextComponent) textComponent)); } else if (fieldDescriptor.isAcceptsFileLocations()) { fieldPanel.add(createFileField((JTextComponent) textComponent)); } else { fieldPanel.add(textComponent); } ((JTextComponent) textComponent).getDocument() .addDocumentListener(new DocumentChangeListener()); } else { fieldPanel.add(textComponent); } fieldDefinitions.put(tmpFieldName, textComponent); containerToAddTo.add(fieldPanel); containerToAddTo.add(Box.createVerticalStrut(5)); } } } }
From source file:org.kuali.test.ui.base.BaseTable.java
@Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component retval = super.prepareRenderer(renderer, row, column); if (retval instanceof JComponent) { JComponent jc = (JComponent) retval; String tooltip = getTooltip(row, column); if (StringUtils.isNotBlank(tooltip)) { jc.setToolTipText(tooltip); }/*from ww w . jav a 2 s. c om*/ } return retval; }
From source file:org.nuclos.client.common.NuclosCollectController.java
protected void setupSearchToolBar() { final Action actSaveFilter = new CommonAbstractAction( getSpringLocaleDelegate().getMessage("NuclosCollectController.9", "Filter speichern"), Icons.getInstance().getIconSave16(), getSpringLocaleDelegate().getMessage( "NuclosCollectController.5", "Eingestelltes Suchkriterium als Filter speichern")) { @Override/* w w w . j a v a2 s . co m*/ public void actionPerformed(ActionEvent ev) { cmdSaveFilter(); } }; final Action actRemoveFilter = new CommonAbstractAction( getSpringLocaleDelegate().getMessage("NuclosCollectController.8", "Filter l\u00f6schen"), Icons.getInstance().getIconDelete16(), getSpringLocaleDelegate() .getMessage("NuclosCollectController.2", "Ausgew\u00e4hlten Filter l\u00f6schen")) { @Override public void actionPerformed(ActionEvent ev) { cmdRemoveFilter(); } }; //result.add(Box.createHorizontalStrut(5)); CenteringPanel cpSearchFilter = new CenteringPanel(getSearchPanel().cmbbxSearchFilter) { @Override public Dimension getMinimumSize() { return this.getCenteredComponent().getMinimumSize(); } @Override public Dimension getMaximumSize() { return this.getCenteredComponent().getPreferredSize(); } }; cpSearchFilter.setOpaque(false); ColoredLabel bl = new ColoredLabel(cpSearchFilter, getSpringLocaleDelegate().getMessage("CollectController.Search.Filter", "Filter")); bl.setName("blChooseFilter"); this.getSearchPanel().addToolBarComponent(bl); //result.add(cpSearchFilter); //result.add(Box.createHorizontalStrut(2)); this.getSearchPanel().addPopupExtraSeparator(); JMenuItem btnSaveFilter = this.getSearchPanel().addPopupExtraMenuItem(new JMenuItem(actSaveFilter)); JMenuItem btnRemoveFilter = this.getSearchPanel().addPopupExtraMenuItem(new JMenuItem(actRemoveFilter)); //final JButton btnSaveFilter = result.add(actSaveFilter); //final JButton btnRemoveFilter = result.add(actRemoveFilter); // disable the remove filter action initially: actRemoveFilter.setEnabled(false); btnSaveFilter.setName("btnSaveFilter"); btnRemoveFilter.setName("btnRemoveFilter"); getSearchPanel().cmbbxSearchFilter.setName("cmbbxSearchFilter"); getSearchPanel().cmbbxSearchFilter.setToolTipText(getSpringLocaleDelegate() .getMessage("NuclosCollectController.15", "W\u00e4hlen Sie hier einen Suchfilter aus")); getSearchPanel().cmbbxSearchFilter.addActionListener(this.alSearchFilter); // set tool tips dynamically: getSearchPanel().cmbbxSearchFilter.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList lst, Object oValue, int index, boolean bSelected, boolean bCellHasFocus) { final JComponent result = (JComponent) super.getListCellRendererComponent(lst, oValue, index, bSelected, bCellHasFocus); String sToolTip = null; if (oValue != null) { final SearchFilter filter = (SearchFilter) oValue; if (result instanceof JLabel && !StringUtils.isNullOrEmpty(filter.getLabelResourceId())) { ((JLabel) result).setText(getSpringLocaleDelegate() .getTextFallback(filter.getLabelResourceId(), filter.getName())); } if (!StringUtils.isNullOrEmpty(filter.getDescriptionResourceId())) { sToolTip = getSpringLocaleDelegate().getTextFallback(filter.getDescriptionResourceId(), filter.getDescriptionResourceId()); } else { sToolTip = filter.getDescription(); } if (filter.getOwner() != null && !(filter.getOwner().equals(Main.getInstance().getMainController().getUserName()))) { sToolTip = sToolTip + " (" + filter.getOwner() + ")"; } result.setToolTipText(sToolTip); } return result; } }); // set the tool tip for the combobox also, as the tool tip for the renderer seems to be // taken in dropped down items only: getSearchPanel().cmbbxSearchFilter.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent ev) { final boolean bSelected = (ev.getStateChange() == ItemEvent.SELECTED); boolean bRegularFilterSelected = bSelected; String sToolTip = null; if (bSelected) { final SearchFilter filter = (SearchFilter) ev.getItem(); assert filter != null; sToolTip = filter.getDescription(); LOG.debug("Filter selected: " + filter.getName()); bRegularFilterSelected = !filter.isDefaultFilter(); } getSearchPanel().cmbbxSearchFilter.setToolTipText(sToolTip); // enable/disable remove filter action - the empty filter cannot be removed: actRemoveFilter.setEnabled(bRegularFilterSelected); } }); //return result; }