當前位置: 首頁>>代碼示例>>Java>>正文


Java JButton.getAction方法代碼示例

本文整理匯總了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();
        }
    });
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:25,代碼來源:GraphEditorTab.java

示例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);
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:54,代碼來源:NbEditorToolBar.java

示例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));
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:6,代碼來源:ShortDescriptionButtonMatcher.java


注:本文中的javax.swing.JButton.getAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。