Java Code Examples for javax.swing.JButton#getToolTipText()
The following examples show how to use
javax.swing.JButton#getToolTipText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShortKeyManager.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
public void setShortCutTo(int key, JButton b) { b.setMnemonic(key); String tt= b.getToolTipText(); if(tt==null) b.setToolTipText("( Alt+" + KeyEvent.getKeyText(key)+" )"); else b.setToolTipText(tt + " ( Alt+" + KeyEvent.getKeyText(key)+" )"); mapping.put(keyfor(b),b); }
Example 2
Source File: NbEditorToolBar.java From netbeans with Apache License 2.0 | 4 votes |
private void refreshToolbarButtons() { final JTextComponent c = getComponent(); final boolean visible = isToolbarVisible(); Runnable r = new Runnable() { public void run() { if (visible) { checkPresentersAdded(); if (c != null) { //#62487 installNoOpActionMappings(); Map<String, MultiKeyBinding> keybsMap = getKeyBindingMap(); Component comps[] = getComponents(); for (int i = 0; i < comps.length; i++) { Component comp = comps[i]; if (comp instanceof JButton) { JButton button = (JButton) comp; Action action = button.getAction(); if (action == null) { continue; } String actionName = (String) action.getValue(Action.NAME); if (actionName == null) { continue; } String tooltipText = button.getToolTipText(); if (tooltipText != null) { int index = tooltipText.indexOf("("); //NOI18N if (index > 0) { tooltipText = tooltipText.substring(0, index - 1); } } MultiKeyBinding mkb = keybsMap.get(actionName); if (mkb != null) { button.setToolTipText(tooltipText + " (" + // NOI18N EditorActionUtilities.getKeyMnemonic(mkb) + ")"); // NOI18N } else { button.setToolTipText(tooltipText); } } } } } else { checkPresentersRemoved(); } setVisible(visible); } }; Utilities.runInEventDispatchThread(r); }