Java Code Examples for javax.swing.JComponent.setToolTipText()

The following are Jave code examples for showing how to use setToolTipText() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: SummaryCellRenderer.java   View Source Code Vote up 6 votes
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        int i = item.getNextFilesToShowCount();
        String tooltip;
        if (i > 0) {
            tooltip = NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ShowMoreFiles", i); //NOI18N
        } else {
            tooltip = NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ShowAllFiles"); //NOI18N
        }
        component.setToolTipText(tooltip);
        return true;
    }
    return false;
}
 
Example 2
Project: incubator-netbeans   File: TableUISupport.java   View Source Code Vote up 5 votes
public Component getTableCellRendererComponent(JTable jTable, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    boolean joinTable = false;
    boolean validClass = true;
    boolean existentUpdate = false;
    String problemDisplayName = null;

    if (jTable.getModel() instanceof TableClassNamesModel) {
        TableClassNamesModel model = (TableClassNamesModel)jTable.getModel();
        Table table = model.getTableAt(row);
        joinTable = table.isJoin();
        if (column == 1) {
            existentUpdate = table.getDisabledReason() instanceof Table.ExistingDisabledReason;
            validClass = model.isValidClass(table);
            if (!validClass) {
                problemDisplayName = model.getProblemDisplayName(table);
            }
        }
    }

    Object realValue = null;
    if (joinTable && column == 1) {
        realValue = NbBundle.getMessage(TableUISupport.class, "LBL_JoinTable");
    } else {
        realValue = value;
    }
    JComponent component = (JComponent)super.getTableCellRendererComponent(jTable, realValue, isSelected, hasFocus, row, column);
    component.setEnabled(!joinTable && !existentUpdate);
    component.setToolTipText(joinTable ? NbBundle.getMessage(TableUISupport.class, "LBL_JoinTableDescription") : problemDisplayName);
    component.setForeground((validClass) ? nonErrorForeground : errorForeground);
   
    return component;
}
 
Example 3
Project: incubator-netbeans   File: OutlineView.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    Component oc = orig.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    if (tooltip == null) {
        tooltip = getShortDescription (value.toString ());
    }
    if ((tooltip != null) && (oc instanceof JComponent)) {
        JComponent jc = (JComponent)oc;
        jc.setToolTipText(tooltip);
    }
    return oc;
}
 
Example 4
Project: incubator-netbeans   File: TooltipWindow.java   View Source Code Vote up 5 votes
@Override
public boolean mouseMoved (Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setToolTipText(Bundle.CTL_AnnotationBar_action_showCommit(revision));
        return true;
    }
    return false;
}
 
Example 5
Project: incubator-netbeans   File: VCSHyperlinkSupport.java   View Source Code Vote up 5 votes
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setToolTipText(NbBundle.getMessage(VCSHyperlinkSupport.class, "LBL_StartChat", author));
        return true;
    }
    return false;
}
 
Example 6
Project: incubator-netbeans   File: SummaryCellRenderer.java   View Source Code Vote up 5 votes
@Override
public boolean mouseMoved (Point p, JComponent component) {
    if (bounds != null && component.getToolTipText() == null) {
        for (Rectangle b : bounds) {
            if (b.contains(p)) {
                component.setToolTipText(text);
                return true;
            }
        }
    }
    return false;
}
 
Example 7
Project: freecol   File: OptionUI.java   View Source Code Vote up 5 votes
/**
 * Set up component.
 */
protected void initialize() {
    JComponent component = getComponent();
    component.setToolTipText(label.getToolTipText());
    component.setEnabled(editable);
    component.setOpaque(false);
}
 
Example 8
Project: incubator-netbeans   File: SummaryCellRenderer.java   View Source Code Vote up 5 votes
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        if (item.revisionExpanded) {
            component.setToolTipText(NbBundle.getMessage(SummaryCellRenderer.class, "MSG_CollapseRevision")); //NOI18N
        } else {
            component.setToolTipText(NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ExpandRevision")); //NOI18N
        }
        return true;
    }
    return false;
}
 
Example 9
Project: incubator-netbeans   File: SummaryCellRenderer.java   View Source Code Vote up 5 votes
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setToolTipText(NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ShowActions")); //NOI18N
        return true;
    }
    return false;
}
 
Example 10
Project: incubator-netbeans   File: TableUISupport.java   View Source Code Vote up 5 votes
public Component getTableCellRendererComponent(JTable jTable, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    boolean joinTable = false;
    boolean validClass = true;
    String problemDisplayName = null;

    if (jTable.getModel() instanceof TableClassNamesModel) {
        TableClassNamesModel model = (TableClassNamesModel)jTable.getModel();
        Table table = model.getTableAt(row);
        joinTable = table.isJoin();
        if (column == 1) {
            validClass = model.isValidClass(table);
            if (!validClass) {
                problemDisplayName = model.getProblemDisplayName(table);
            }
        }
    }

    Object realValue = null;
    if (joinTable && column == 1) {
        realValue = NbBundle.getMessage(TableUISupport.class, "LBL_JoinTable");
    } else {
        realValue = value;
    }
    JComponent component = (JComponent)super.getTableCellRendererComponent(jTable, realValue, isSelected, hasFocus, row, column);
    component.setEnabled(!joinTable);
    component.setToolTipText(joinTable ? NbBundle.getMessage(TableUISupport.class, "LBL_JoinTableDescription") : problemDisplayName);
    component.setForeground((validClass) ? nonErrorForeground : errorForeground);
   
    return component;
}
 
Example 11
Project: incubator-netbeans   File: TooltipWindow.java   View Source Code Vote up 5 votes
@Override
public boolean mouseMoved (Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setToolTipText(Bundle.CTL_AnnotationBar_action_showCommit(revision));
        return true;
    }
    return false;
}
 
Example 12
Project: Logisim   File: ProjectExplorer.java   View Source Code Vote up 5 votes
@Override
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
		boolean expanded, boolean leaf, int row, boolean hasFocus) {
	java.awt.Component ret;
	ret = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

	if (ret instanceof JComponent) {
		JComponent comp = (JComponent) ret;
		comp.setToolTipText(null);
	}
	if (value instanceof Tool) {
		Tool tool = (Tool) value;
		if (ret instanceof JLabel) {
			((JLabel) ret).setText(tool.getDisplayName());
			((JLabel) ret).setIcon(new ToolIcon(tool));
			((JLabel) ret).setToolTipText(tool.getDescription());
		}
	} else if (value instanceof Library) {
		if (ret instanceof JLabel) {
			Library lib = (Library) value;
			String text = lib.getDisplayName();
			if (lib.isDirty())
				text += DIRTY_MARKER;
			((JLabel) ret).setText(text);
		}
	}
	return ret;
}
 
Example 13
Project: Cognizant-Intelligent-Test-Scripter   File: AbstractRenderer.java   View Source Code Vote up 4 votes
protected void setDefault(JComponent comp) {
    comp.setForeground(Color.BLACK);
    comp.setToolTipText(null);
}
 
Example 14
Project: incubator-netbeans   File: CategoryList.java   View Source Code Vote up 4 votes
@Override
public Component getListCellRendererComponent (JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
    CategoryList categoryList = (CategoryList) list;
    boolean showNames = categoryList.getShowNames ();
    int iconSize = categoryList.getIconSize ();
    
    JComponent rendererComponent = toolbar != null ? toolbar : button;

    Item item = (Item) value;
    Image icon = item.getIcon (iconSize);
    if (icon != null) {
        button.setIcon (new ImageIcon (icon));
    }

    button.setText (showNames ? item.getDisplayName () : null);
    rendererComponent.setToolTipText( item.getShortDescription() ); // NOI18N

    button.setSelected (isSelected);
    //if (defaultBorder == null) { // Windows or Metal
        // let the toolbar UI render the button according to "rollover"
        button.getModel ().setRollover (index == categoryList.rolloverIndex && !isSelected);
    /*} else { // Mac OS X and others - set the border explicitly
        button.setBorder (defaultBorder);
    }*/
    button.setBorderPainted ((index == categoryList.rolloverIndex) || isSelected);

    button.setHorizontalAlignment (showNames ? SwingConstants.LEFT : SwingConstants.CENTER);
    button.setHorizontalTextPosition (SwingConstants.RIGHT);
    button.setVerticalTextPosition (SwingConstants.CENTER);
    Color c = new Color(UIManager.getColor("Tree.background").getRGB()); //NOI18N
    if( isNimbus )
        toolbar.setBackground(c);
    if( isGTK )
        button.setBackground(c);

    return rendererComponent;
}
 
Example 15
Project: Tarski   File: Visualization.java   View Source Code Vote up 4 votes
private void addMouseMotionAdaper() {
  final MouseMotionAdapter adapter = new MouseMotionAdapter() {

    @Override
    public void mouseMoved(final MouseEvent e) {
      final Object annotation =
          graph.alloyGetViewer().alloyGetAnnotationAtXY(e.getX(), e.getY());
      final JComponent cmpnt = (JComponent) e.getComponent();
      String tooltip = null;

      if (annotation instanceof AlloyAtom) {
        graphInPanel.setCursor(new Cursor(Cursor.HAND_CURSOR));

        final String id = Utility.itemIdByAlloyAtom((AlloyAtom) annotation);
        final String atomName = Utility.getAtomNameById(id);

        tooltip = atomName;
      } else if (annotation instanceof AlloyTuple) {
        final AlloyTuple tuple = (AlloyTuple) annotation;

        final AlloyAtom highLightedAtomStart = tuple.getStart();
        final AlloyAtom highLightedAtomEnd = tuple.getEnd();

        final String fromId = Utility.itemIdByAlloyAtom(highLightedAtomStart);
        final String toId = Utility.itemIdByAlloyAtom(highLightedAtomEnd);
        if (fromId == null || toId == null) {
          return;
        }
        final String fromAtomName = Utility.getAtomNameById(fromId);
        final String toAtomName = Utility.getAtomNameById(toId);

        tooltip = fromAtomName + " --> " + toAtomName;

        graphInPanel.setCursor(new Cursor(Cursor.HAND_CURSOR));
      } else {
        graphInPanel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      }

      cmpnt.setToolTipText(tooltip);

    }
  };
  graph.alloyGetViewer().addMouseMotionListener(adapter);
  graphInPanel.addMouseMotionListener(adapter);

}
 
Example 16
Project: Cognizant-Intelligent-Test-Scripter   File: AbstractRenderer.java   View Source Code Vote up 4 votes
protected void setNotPresent(JComponent comp, String notPresent) {
    comp.setForeground(Color.RED);
    comp.setToolTipText(notPresent);
}
 
Example 17
Project: Cognizant-Intelligent-Test-Scripter   File: AbstractRenderer.java   View Source Code Vote up 4 votes
protected void setEmpty(JComponent comp) {
    comp.setBorder(errorBorder);
    comp.setToolTipText(empty);
}
 
Example 18
Project: JavaGraph   File: LabelTree.java   View Source Code Vote up 4 votes
@Override
public JComponent getTreeCellRendererComponent(JTree tree, Object value, boolean sel,
        boolean expanded, boolean leaf, int row, boolean hasFocus) {
    JComponent result =
        super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    // set a sub- or supertype icon if the node label is a subnode
    Icon labelIcon = null;
    if (getTreeNode() instanceof LabelTree.EntryNode) {
        EntryNode entryNode = (EntryNode) getTreeNode();
        Entry entry = entryNode.getEntry();
        labelIcon = entryNode.getIcon();
        // set tool tip text
        StringBuilder toolTipText = new StringBuilder();
        Set<JCell<G>> occurrences = getFilter().getJCells(entry);
        int count = occurrences == null ? 0 : occurrences.size();
        toolTipText.append(count);
        toolTipText.append(" occurrence");
        if (count != 1) {
            toolTipText.append("s");
        }
        if (isFiltering()) {
            if (toolTipText.length() != 0) {
                toolTipText.append(HTMLConverter.HTML_LINEBREAK);
            }
            if (getFilter().isSelected(entry)) {
                toolTipText.append("Visible label; doubleclick to filter");
            } else {
                toolTipText.append("Filtered label; doubleclick to show");
            }
        }
        if (toolTipText.length() != 0) {
            result.setToolTipText(HTMLConverter.HTML_TAG.on(toolTipText).toString());
        }
        // set node colour
        if (entry instanceof TypeEntry) {
            TypeElement typeElement = ((TypeEntry) entry).getType();
            TypeNode typeNode =
                typeElement instanceof TypeNode ? (TypeNode) typeElement
                        : ((TypeEdge) typeElement).source();
            Color color = typeNode.getColor();
            if (color != null) {
                getInner().setForeground(color);
            }
        }
    }
    getInner().setIcon(labelIcon);
    return result;
}
 
Example 19
Project: FreeCol   File: Utility.java   View Source Code Vote up 2 votes
/**
 * Localize the tool tip message for a JComponent.
 *
 * @param comp The {@code JComponent} to localize.
 * @param key The key to use.
 * @return The original {@code JComponent}.
 */
public static JComponent localizeToolTip(JComponent comp, String key) {
    comp.setToolTipText(Messages.message(key));
    return comp;
}
 
Example 20
Project: freecol   File: Utility.java   View Source Code Vote up 2 votes
/**
 * Localize the tool tip message for a JComponent.
 *
 * @param comp The {@code JComponent} to localize.
 * @param template The {@code StringTemplate} to use.
 * @return The original {@code JComponent}.
 */
public static JComponent localizeToolTip(JComponent comp,
                                         StringTemplate template) {
    comp.setToolTipText(Messages.message(template));
    return comp;
}