本文整理汇总了Java中javax.swing.JButton.getAction方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.getAction方法的具体用法?Java JButton.getAction怎么用?Java JButton.getAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.getAction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processToolBar
import javax.swing.JButton; //导入方法依赖的package包/类
/** Post-processes an already constructed toolbar.
*/
private void processToolBar(JToolBar toolBar) {
for (int i = 0; i < toolBar.getComponentCount(); i++) {
Component element = toolBar.getComponent(i);
if (element instanceof JButton) {
JButton button = (JButton) element;
Action action = button.getAction();
if (action != null) {
getJGraph().addAccelerator(action);
}
}
}
// ensure the JGraph gets focus as soon as the graph panel
// is clicked anywhere
// for reasons not clear to me, mouse listeners do not work on
// the level of the JGraphPanel
toolBar.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
getJGraph().requestFocus();
}
});
}
示例2: refreshToolbarButtons
import javax.swing.JButton; //导入方法依赖的package包/类
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);
}
示例3: isMatching
import javax.swing.JButton; //导入方法依赖的package包/类
@Override
protected boolean isMatching(JButton button) {
return button.getAction() != null &&
textToMatch.equals(button.getAction().getValue(Action.SHORT_DESCRIPTION));
}