当前位置: 首页>>代码示例>>Java>>正文


Java AbstractButton.getAction方法代码示例

本文整理汇总了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 ?
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:NbEditorToolBar.java

示例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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:31,代码来源:BubbleWindow.java

示例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();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:CompositeMenuToggleButton.java

示例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);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:17,代码来源:FreeColPanel.java


注:本文中的javax.swing.AbstractButton.getAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。