本文整理汇总了Java中javax.swing.AbstractButton.getAction方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractButton.getAction方法的具体用法?Java AbstractButton.getAction怎么用?Java AbstractButton.getAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.AbstractButton
的用法示例。
在下文中一共展示了AbstractButton.getAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTooltip
import javax.swing.AbstractButton; //导入方法依赖的package包/类
private static void updateTooltip(AbstractButton b, List<? extends MultiKeyBinding> keybindings) {
Action a = b.getAction();
String actionName = a == null ? null : (String) a.getValue(Action.NAME);
if (actionName == null) {
// perhaps no action at all
return;
}
for (MultiKeyBinding mkb : keybindings) {
if (actionName.equals(mkb.getActionName())) {
b.setToolTipText(b.getToolTipText() + " (" + // NOI18N
EditorActionUtilities.getKeyMnemonic(mkb) + ")"); // NOI18N
break; // multiple shortcuts ?
}
}
}
示例2: findButton
import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
* @param name
* i18nKey of the Button
* @param searchRoot
* {@link Component} in which will be searched for the Button
* @return returns the {@link AbstractButton} or null if the Button was not found.
*/
public static AbstractButton findButton(final String name, final Component searchRoot) {
if (searchRoot instanceof AbstractButton) {
AbstractButton b = (AbstractButton) searchRoot;
if (b.getAction() instanceof ResourceAction) {
String id = (String) b.getAction().getValue("rm_id");
if (name.equals(id)) {
return b;
}
}
}
if (searchRoot instanceof Container) {
Component[] all = ((Container) searchRoot).getComponents();
for (Component child : all) {
AbstractButton result = findButton(name, child);
if (result != null) {
return result;
}
}
}
return null;
}
示例3: setSelected
import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
* Selects the given action in the menu. This methods also updates the selection status of the
* toggle button.
*
* @param action
* the action which should be selected
*/
public void setSelected(Action action) {
Enumeration<AbstractButton> menuEnum = popupMenuGroup.getElements();
boolean found = false;
while (menuEnum.hasMoreElements()) {
AbstractButton button = menuEnum.nextElement();
if (action == button.getAction()) {
button.setSelected(true);
found = true;
} else {
button.setSelected(false);
}
}
if (found) {
setFont(getFont().deriveFont(Font.BOLD));
updateSelectionStatus();
} else {
setFont(getFont().deriveFont(Font.PLAIN));
clearMenuSelection();
}
}
示例4: setCancelComponent
import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
* Make the given button the CANCEL button.
*
* @param cancelButton an {@code AbstractButton} value
*/
public final void setCancelComponent(AbstractButton cancelButton) {
if (cancelButton == null) throw new NullPointerException();
InputMap inputMap
= getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true),
"release");
Action cancelAction = cancelButton.getAction();
getActionMap().put("release", cancelAction);
}