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


Java AbstractAction類代碼示例

本文整理匯總了Java中javax.swing.AbstractAction的典型用法代碼示例。如果您正苦於以下問題:Java AbstractAction類的具體用法?Java AbstractAction怎麽用?Java AbstractAction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AbstractAction類屬於javax.swing包,在下文中一共展示了AbstractAction類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPreferredAction

import javax.swing.AbstractAction; //導入依賴的package包/類
/**
 * On default select the represented agent and do the former original action
 * @return
 */
@Override
public Action getPreferredAction() {
    return new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            IPogamutEnvironments environments = Lookup.getDefault().lookup(IPogamutEnvironments.class);
            if (environments == null)
                return;

            environments.getEnvironmentSelection(map).changeSelected(agent);
            
            // Do the original action
            Action original = UnrealAgentNode.super.getPreferredAction();
            if (original != null)
                original.actionPerformed(e);
        }
    };
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:24,代碼來源:UnrealAgentNode.java

示例2: initialize

import javax.swing.AbstractAction; //導入依賴的package包/類
/**
 * This method initializes this
 *
 * @return void
 */
private void initialize() {
    setLayout(new BorderLayout());
    this.setSize(581, 39);
    this.add(getJPanel(), java.awt.BorderLayout.WEST);
    setFocusable(true);
    final AbstractAction aa = new AbstractAction() {

        /**
         *
         */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            findNext(jTextField.getText(), jCheckBox.isSelected());
        }

    };

    this.getInputMap().put(KeyStroke.getKeyStroke("F3"), "FindNext");
    this.getActionMap().put("FindNext", aa);
    getJTextField().getInputMap().put(KeyStroke.getKeyStroke("F3"),
            "FindNext");
    getJTextField().getActionMap().put("FindNext", aa);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:30,代碼來源:FindPanel.java

示例3: ViewAsMenuItem

import javax.swing.AbstractAction; //導入依賴的package包/類
public ViewAsMenuItem(final String type) {
    super(new AbstractAction(NbBundle.getMessage(NumericDisplayFilter.class, "CTL_View_"+type)) {
            @Override
            public void actionPerformed(ActionEvent e) {
                onViewAs(type, true);
            }
        });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:VariablesSwitchViewAction.java

示例4: getPopupPresenter

import javax.swing.AbstractAction; //導入依賴的package包/類
public JMenuItem getPopupPresenter() {
    JMenu displayAsPopup = new JMenu();
    Mnemonics.setLocalizedText(displayAsPopup, NbBundle.getMessage(DebuggingActionsProvider.class, "CTL_Session_Popup_Language"));

    String [] languages = session.getSupportedLanguages();
    String currentLanguage = session.getCurrentLanguage();
    for (int i = 0; i < languages.length; i++) {
        final String language = languages[i];
        JRadioButtonMenuItem langItem = new JRadioButtonMenuItem(new AbstractAction(language) {
            public void actionPerformed(ActionEvent e) {
                session.setCurrentLanguage(language);
            }
        });
        if (currentLanguage.equals(language)) langItem.setSelected(true);
        displayAsPopup.add(langItem);
    }
    return displayAsPopup;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:DebuggingActionsProvider.java

示例5: getActions

import javax.swing.AbstractAction; //導入依賴的package包/類
@Override
public Action[] getActions(boolean context) {
    Action[] res = new Action[2];
    res[0] = new AbstractAction(NbBundle.getMessage(HiddenDataObject.class, "LBL_restore")) { //NOI18N
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                destroy();
            } catch( IOException ex ) {
                Exceptions.printStackTrace(ex);
            }
        }
    };
    res[0].setEnabled(canDestroy());
    res[1] = SystemAction.get(OpenLayerFilesAction.class);
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:HiddenDataObject.java

示例6: testGlobalChanges

import javax.swing.AbstractAction; //導入依賴的package包/類
public void testGlobalChanges() throws Exception {
    class MyAction extends AbstractAction {
        public int cntEnabled;
        public int cntPerformed;
        
        public boolean isEnabled() {
            cntEnabled++;
            return true;
        }
        
        public void actionPerformed(ActionEvent ev) {
            cntPerformed++;
        }
    }
    MyAction myAction = new MyAction();
    
    ActionMap tc = new ActionMap();
    tc.put(DefaultEditorKit.copyAction, myAction);
    CopyAction a = (CopyAction)CopyAction.get(CopyAction.class);
    
    ActionsInfraHid.setActionMap(tc);
    try {
        assertTrue("MyAction is enabled", a.isEnabled());
        assertEquals("isEnabled called once", 1, myAction.cntEnabled);
        a.setActionPerformer(null);
        assertEquals("An enabled is currentlly called again", 2, myAction.cntEnabled);
    } finally {
        ActionsInfraHid.setActionMap(null);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:CallbackSystemActionTest.java

示例7: getActions

import javax.swing.AbstractAction; //導入依賴的package包/類
@Override
public Action[] getActions() {
    Action refresh = new AbstractAction() {

        {
            putValue(ACTION_COMMAND_KEY, "refresh_current_page");
            putValue(SMALL_ICON, new ImageIcon(getClass().getResource(
                    "/com/ramussoft/gui/refresh.png")));
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R,
                    KeyEvent.CTRL_MASK));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            pane.getDocument().putProperty(
                    Document.StreamDescriptionProperty, null);
            openLocation();
        }
    };
    return new Action[]{goBack, goForward, goHome, refresh, null,
            exportToHTMLAction};
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:23,代碼來源:Navigator.java

示例8: getPreferredAction

import javax.swing.AbstractAction; //導入依賴的package包/類
@Override
public Action getPreferredAction () {
    if (options.contains(Option.ENABLE_POPUP)) {
        if (currRepository != null && item != null) {
            final File repo = currRepository;
            final int index = item.getIndex();
            return new AbstractAction(NbBundle.getMessage(ApplyStashAction.class, "LBL_ApplyStashAction_PopupName")) { //NOI18N
                @Override
                public void actionPerformed (ActionEvent e) {
                    SystemAction.get(ApplyStashAction.class).applyStash(repo, index, false);
                }
            };
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:RepositoryBrowserPanel.java

示例9: getUserActions

import javax.swing.AbstractAction; //導入依賴的package包/類
@Override
public Action[] getUserActions () {
    List<Action> actions = new ArrayList<Action>();
    boolean hasParents = event.getLogInfoHeader().getLog().getParents().length > 0;
    
    if (hasParents) {
        actions.add(new AbstractAction(NbBundle.getMessage(SummaryView.class, "CTL_SummaryView_DiffToPrevious")) { // NOI18N
            @Override
            public void actionPerformed(ActionEvent e) {
                diffPrevious(event, master);
            }
        });
    }
    actions.addAll(Arrays.asList(event.getActions(false)));
    return actions.toArray(new Action[actions.size()]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:SummaryView.java

示例10: DetailsButton

import javax.swing.AbstractAction; //導入依賴的package包/類
public DetailsButton(String showText, String hideText,
                     Component expander, Component buddy) {
  this.showText = showText;
  this.hideText = hideText;

  if (expander != null) setExpander(expander);

  setAction(new AbstractAction(showText, collapsedIcon) {
    private static final long serialVersionUID = 1L;

    public void actionPerformed(ActionEvent e) {
      setExpanded(!DetailsButton.this.expander.isVisible());
    }
  });

  if (buddy != null) setBuddy(buddy);

  setBorderPainted(false);
  setContentAreaFilled(false);
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:21,代碼來源:DetailsButton.java

示例11: createContextAwareInstance

import javax.swing.AbstractAction; //導入依賴的package包/類
@Messages("BTN_Open_Project=Open Project")
public @Override Action createContextAwareInstance(final Lookup context) {
    return new AbstractAction(BTN_Open_Project()) {
        public @Override void actionPerformed(ActionEvent e) {
            Collection<? extends NbMavenProjectImpl> projects = context.lookupAll(NbMavenProjectImpl.class);
            final NbMavenProjectImpl[] projectsArray = projects.toArray(new NbMavenProjectImpl[0]);
            if(projectsArray.length > 0) {
                RequestProcessor.getDefault().post(new Runnable() {
                    public @Override void run() {
                        OpenProjects.getDefault().open(projectsArray, false, true);
                        RequestProcessor.getDefault().post(new Runnable() {
                            public @Override void run() {
                                ProjectActionUtils.selectAndExpandProject(projectsArray[0]);
                            }
                        }, 500);    
                    }
                });
            }
        }
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:ModulesNode.java

示例12: createContextAwareInstance

import javax.swing.AbstractAction; //導入依賴的package包/類
public @Override Action createContextAwareInstance(final Lookup context) {
    return new AbstractAction(BTN_Open_Project()) {
        public @Override void actionPerformed(ActionEvent e) {
            Set<Project> projects = new HashSet<Project>();
            for (Artifact art : context.lookupAll(Artifact.class)) {
                File f = art.getFile();
                if (f != null) {
                    Project p = FileOwnerQuery.getOwner(org.openide.util.Utilities.toURI(f));
                    if (p != null) {
                        projects.add(p);
                    }
                }
            }
            OpenProjects.getDefault().open(projects.toArray(new NbMavenProjectImpl[projects.size()]), false, true);
        }
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:DependencyNode.java

示例13: inserirAtalhos

import javax.swing.AbstractAction; //導入依賴的package包/類
private void inserirAtalhos() {
    InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    getRootPane().setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);

    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelar");

    getRootPane().getActionMap().put("cancelar", new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent arg0) {
            jPanelCards.removeAll();
            dispose();
        }
    });
}
 
開發者ID:limagiran,項目名稱:hearthstone,代碼行數:17,代碼來源:EscolherCard.java

示例14: getActions

import javax.swing.AbstractAction; //導入依賴的package包/類
Action[] getActions () {
    List<Action> actions = new ArrayList<Action>();
    actions.add(new AbstractAction(NbBundle.getMessage(RepositoryRevision.class, "CTL_SummaryView_RollbackChange")) { //NOI18N
        @Override
        public void actionPerformed(ActionEvent e) {
            SvnProgressSupport support = new SvnProgressSupport() {
                @Override
                public void perform() {
                    RevertModifications.RevisionInterval revisionInterval = new RevertModifications.RevisionInterval(getLog().getRevision());
                    final Context ctx = new Context(selectionRoots);
                    RevertModificationsAction.performRevert(revisionInterval, false, false, ctx, this);
                }
            };
            support.start(Subversion.getInstance().getRequestProcessor(repositoryRootUrl),
                    repositoryRootUrl, NbBundle.getMessage(SummaryView.class, "MSG_Revert_Progress")); //NOI18N
        }
    });
    return actions.toArray(new Action[actions.size()]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:RepositoryRevision.java

示例15: createButton

import javax.swing.AbstractAction; //導入依賴的package包/類
/**
 * Helper method used to create a button inside a JPanel
 * @param action action associated to that button
 * @return created component
 */
private JComponent createButton(AbstractAction action) {
	JPanel panel = new JPanel(); // Use gridbag as centers by default
	JButton button = new JButton(action);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
	button.addMouseListener(rollover);
	//if (action == buttonAction[4]) {
	//	button.setVisible(false);
	//}
	//if (action == buttonAction[0]) {
	//	button.setEnabled(false);
	//}
	//if (action == buttonAction[2]) button.setEnabled(false);
	//if (action == buttonAction[4]) button.setEnabled(false);
	panel.add(button);
	return panel;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:24,代碼來源:JWatMainPanel.java


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