當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。