本文整理汇总了Java中javax.swing.JComponent.setToolTipText方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.setToolTipText方法的具体用法?Java JComponent.setToolTipText怎么用?Java JComponent.setToolTipText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.setToolTipText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseMoved
import javax.swing.JComponent; //导入方法依赖的package包/类
@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;
}
示例2: getTableCellRendererComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
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;
}
示例3: getTableCellRendererComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
@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;
}
示例4: mouseMoved
import javax.swing.JComponent; //导入方法依赖的package包/类
@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;
}
示例5: mouseMoved
import javax.swing.JComponent; //导入方法依赖的package包/类
@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;
}
示例6: initialize
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* Set up component.
*/
protected void initialize() {
JComponent component = getComponent();
component.setToolTipText(label.getToolTipText());
component.setEnabled(editable);
component.setOpaque(false);
}
示例7: getTableCellRendererComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
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;
}
示例8: getTreeCellRendererComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
@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;
}
示例9: setDefault
import javax.swing.JComponent; //导入方法依赖的package包/类
protected void setDefault(JComponent comp) {
comp.setForeground(Color.BLACK);
comp.setToolTipText(null);
}
示例10: getListCellRendererComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
@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;
}
示例11: addMouseMotionAdaper
import javax.swing.JComponent; //导入方法依赖的package包/类
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);
}
示例12: setNotPresent
import javax.swing.JComponent; //导入方法依赖的package包/类
protected void setNotPresent(JComponent comp, String notPresent) {
comp.setForeground(Color.RED);
comp.setToolTipText(notPresent);
}
示例13: setEmpty
import javax.swing.JComponent; //导入方法依赖的package包/类
protected void setEmpty(JComponent comp) {
comp.setBorder(errorBorder);
comp.setToolTipText(empty);
}
示例14: getTreeCellRendererComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
@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;
}
示例15: localizeToolTip
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* 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;
}