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:Main.java
public static void main(String[] argv) throws Exception { JTable table = new JTable() { public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) { Component c = super.prepareRenderer(renderer, rowIndex, vColIndex); if (c instanceof JComponent) { JComponent jc = (JComponent) c; jc.setToolTipText((String) getValueAt(rowIndex, vColIndex)); }/*from w ww . j a va 2 s . c om*/ return c; } }; }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JComponent button = new JButton("Cut"); String tooltiptext = "<html>" + "This is the " + "<img src=\"file:cut.gif\">" + " tool tip text." + "</html>"; button.setToolTipText(tooltiptext); JPanel panel = new JPanel(); panel.add(button);// w w w . j ava2 s. c o m frame.add(panel, BorderLayout.CENTER); frame.setSize(400, 400); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); JComponent jc = (JComponent) c; jc.setToolTipText((row + 1) + "x" + (column + 1) + "=" + ((row + 1) * (column + 1))); return jc;/* w ww . j av a 2 s . c o m*/ }
From source file:org.jdal.swing.validation.BackgroundErrorProcessor.java
/** * {@inheritDoc}/*from w ww. jav a 2 s. c o m*/ */ public void reset() { for (JComponent c : colorMap.keySet()) { c.setBackground(colorMap.get(c)); c.setToolTipText(null); } colorMap.clear(); }
From source file:org.jdal.swing.validation.BackgroundErrorProcessor.java
/** * {@inheritDoc}//from w w w . ja v a 2s .com */ public void processError(Object control, FieldError error) { if (control instanceof JComponent) { JComponent c = (JComponent) control; colorMap.put(c, c.getBackground()); ((JComponent) c).setBackground(errorColor); if (messageSource != null) c.setToolTipText(messageSource.getMessage(error, null)); } }
From source file:de.unentscheidbar.validation.swing.trigger.FocusLossTriggerTest.java
@Override protected void doNotProvokeTrigger(Iterable<JComponent> components) { for (final JComponent c : components) { runInEdt(new Callable<Void>() { @Override/*from ww w .j ava2 s .com*/ public Void call() throws Exception { if (c instanceof JTextComponent) { ((JTextComponent) c).setText(RandomStringUtils.randomAlphanumeric(rnd.nextInt(16))); } else { c.setToolTipText(RandomStringUtils.randomAlphanumeric(rnd.nextInt(16))); } return null; } }); } drainEventQueue(); }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.table.JTableInfoForCMFolder.java
synchronized public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);/*from www .j a v a 2 s.co m*/ if (value == null) { comp.setToolTipText(null); return comp; } comp.setToolTipText(String.valueOf(value)); if (row >= table.getRowCount()) { log.debug("row > table.getRowCount()"); return comp; } switch (column) { case TableModelForCMFolder.COL_COMPONENT_NAME: case TableModelForCMFolder.COL_LICENSE_NAME: setHorizontalAlignment(SwingConstants.LEFT); break; case TableModelForCMFolder.COL_VERSION_NAME: case TableModelForCMFolder.COL_IDENTIFIED: case TableModelForCMFolder.COL_STATUS: case TableModelForCMFolder.COL_PENDING: setHorizontalAlignment(SwingConstants.CENTER); break; } int pendingHits = 0; int identifiedHits = 0; if (table.getValueAt(row, TableModelForCMFolder.COL_PENDING) != null) { pendingHits = Tools .transStringToInteger(table.getValueAt(row, TableModelForCMFolder.COL_PENDING).toString()); } if (table.getValueAt(row, TableModelForCMFolder.COL_IDENTIFIED) != null) { identifiedHits = Tools .transStringToInteger(table.getValueAt(row, TableModelForCMFolder.COL_IDENTIFIED).toString()); } if (identifiedHits > 0 && pendingHits == 0) { comp.setFont(new Font("Arial", Font.BOLD, 12)); comp.setForeground(NORMAL_COLOR); } else if (identifiedHits == 0 && pendingHits == 0) { comp.setForeground(GRAY_COLOR); } else { comp.setForeground(NORMAL_COLOR); } return comp; }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.table.JTableInfoForCMFile.java
synchronized public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);/*from w w w. jav a 2 s .co m*/ if (value == null) { comp.setToolTipText(null); return comp; } comp.setToolTipText(String.valueOf(value)); if (row >= table.getRowCount()) { log.debug("row > table.getRowCount()"); return comp; } switch (column) { case TableModelForCMFile.COL_COMPONENT_NAME: case TableModelForCMFile.COL_LICENSE_NAME: setHorizontalAlignment(SwingConstants.LEFT); break; case TableModelForCMFile.COL_VERSION_NAME: case TableModelForCMFile.COL_USAGE: case TableModelForCMFile.COL_STATUS: case TableModelForCMFile.COL_PERCENTAGE: case TableModelForCMFile.COL_MATCHED_FILE: setHorizontalAlignment(SwingConstants.CENTER); break; } if (table.getValueAt(row, TableModelForCMFile.COL_STATUS) == null) return comp; String status = table.getValueAt(row, TableModelForCMFile.COL_STATUS).toString(); String licenseName = table.getValueAt(row, TableModelForCMFile.COL_LICENSE_NAME).toString(); if (status.equals(AbstractMatchInfo.IDENTIFIED)) { comp.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 12)); comp.setForeground(NORMAL_COLOR); } else if ((status.equals(AbstractMatchInfo.REJECTED)) || (status.equals(AbstractMatchInfo.DECLARED))) { comp.setForeground(new Color(150, 150, 150)); } else if (status.equals(AbstractMatchInfo.PENDING)) { if (identifiedStringSearchLicense != null && !identifiedStringSearchLicense.equals("")) { String currentRowLicense = "" + licenseName; if (identifiedStringSearchLicense.equals(currentRowLicense)) { comp.setForeground(NORMAL_COLOR); } else { comp.setForeground(GRAY_COLOR); } } else { comp.setForeground(NORMAL_COLOR); } } return comp; }
From source file:com.t3.macro.api.functions.input.ColumnPanel.java
/** * Adds a row to the ColumnPanel with a label and input field. * <code>addToVarList</code> controls whether the VarSpec is added to * the local listing.//from w ww. j a v a 2 s.c o m */ protected void addVariable(VarSpec vs, boolean addToVarList) { if (addToVarList) varSpecs.add(vs); gbc.gridy = componentCount; gbc.gridwidth = 1; // add the label gbc.gridx = 0; JComponent l; Matcher m = Pattern.compile("^\\s*<html>(.*)<\\/html>\\s*$").matcher(vs.prompt); if (m.find()) { // For HTML values we use a HTMLPane. HTMLPane htmlp = new HTMLPane(); htmlp.setText("<html>" + m.group(1) + ":</html>"); htmlp.setBackground(Color.decode("0xECE9D8")); l = htmlp; } else { l = new JLabel(vs.prompt + ":"); } labels.add(l); if (!vs.optionValues.optionEquals("SPAN", "TRUE")) { // if the control is not set to span, we include the prompt label add(l, gbc); } // add the input component JComponent inputField = createInputControl(vs); if (vs.optionValues.optionEquals("SPAN", "TRUE")) { gbc.gridwidth = 2; // the control spans both columns inputField.setToolTipText(vs.prompt); } else { gbc.gridx = 1; // the control lives in the second column } inputFields.add(inputField); add(inputField, gbc); componentCount++; }
From source file:com.eviware.soapui.support.components.SimpleForm.java
private void setToolTip(JComponent component, String tooltip) { component.setToolTipText(StringUtils.defaultIfEmpty(tooltip, null)); }