Java 类javax.swing.AbstractAction 实例源码

项目:Pogamut3    文件:UnrealAgentNode.java   
/**
 * 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);
        }
    };
}
项目:ramus    文件:FindPanel.java   
/**
 * 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);
}
项目:incubator-netbeans    文件:DebuggingActionsProvider.java   
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;
}
项目:incubator-netbeans    文件:HiddenDataObject.java   
@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;
}
项目:ramus    文件:Navigator.java   
@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};
}
项目:incubator-netbeans    文件:RepositoryBrowserPanel.java   
@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;
}
项目:incubator-netbeans    文件:SummaryView.java   
@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()]);
}
项目:VASSAL-src    文件:DetailsButton.java   
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);
}
项目:incubator-netbeans    文件:ModulesNode.java   
@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);    
                    }
                });
            }
        }
    };
}
项目:incubator-netbeans    文件:DependencyNode.java   
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);
        }
    };
}
项目:hearthstone    文件:EscolherCard.java   
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();
        }
    });
}
项目:incubator-netbeans    文件:RepositoryRevision.java   
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()]);
}
项目:jmt    文件:JWatMainPanel.java   
/**
 * 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;
}
项目:VASSAL-src    文件:ConfigureTree.java   
protected Action buildDeleteAction(final Configurable target) {
  final DefaultMutableTreeNode targetNode = getTreeNode(target);
  final Configurable parent = getParent(targetNode);
  if (targetNode.getParent() != null) {
    return new AbstractAction(deleteCmd) {
      private static final long serialVersionUID = 1L;

      public void actionPerformed(ActionEvent evt) {
        int row = selectedRow;
        remove(parent, target);
        if (row < getRowCount()) {
          setSelectionRow(row);
        }
        else {
          setSelectionRow(row - 1);
        }
      }
    };
  }
  else {
    return null;
  }
}
项目:jmt    文件:JWatStartScreen.java   
private void initGUI() {
    this.setIconImage(JMTImageLoader.loadImage(IMG_JWATICON).getImage());
    this.setResizable(false);
    this.setTitle("JWAT");
    this.setSize(CommonConstants.MAX_GUI_WIDTH_JWAT_STARTSCREEN, CommonConstants.MAX_GUI_HEIGHT_JWAT_STARTSCREEN);
    //Image image = new ImageIcon(imageURL).getImage();
    //image = image.getScaledInstance(400, 315, Image.SCALE_SMOOTH);
    JPanel eastPanel = new JPanel(new BorderLayout());
    eastPanel.add(Box.createVerticalStrut(5), BorderLayout.NORTH);
    JPanel buttonPanel = new JPanel(new GridLayout(buttonAction.length, 1, 2, 2));
    eastPanel.add(buttonPanel, BorderLayout.CENTER);
    for (AbstractAction element : buttonAction) {
        buttonPanel.add(createButton(element));
    }
    JLabel imageLabel = new JLabel();
    imageLabel.setBorder(BorderFactory.createEmptyBorder(BUTTONSIZE - 5, 1, 0, 0));
    //imageLabel.setIcon(new ImageIcon(image));
    imageLabel.setIcon(new ImageIcon(new ImageIcon(imageURL).getImage().getScaledInstance(400, 315, Image.SCALE_SMOOTH)));
    imageLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    imageLabel.setVerticalAlignment(SwingConstants.NORTH);
    this.getContentPane().add(imageLabel, BorderLayout.CENTER);
    this.getContentPane().add(eastPanel, BorderLayout.EAST);
}
项目:rapidminer    文件:FileChooserUI.java   
protected ActionMap createActions() {
    final AbstractAction escAction = new AbstractAction() {

        private static final long serialVersionUID = -3976059968191425942L;

        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserUI.this.fileList.stopThumbnailGeneration();
            getFileChooser().cancelSelection();
        }

        @Override
        public boolean isEnabled() {
            return getFileChooser().isEnabled();
        }
    };
    final ActionMap map = new ActionMapUIResource();
    map.put("approveSelection", getApproveSelectionAction());
    map.put("cancelSelection", escAction);
    return map;
}
项目:incubator-netbeans    文件:DocumentsDlg.java   
private JPanel createListView () {
    JPanel panel = new JPanel();
    // Defined size in #36907 - surrounding controls will add to this size
    // and result is desired 540x400. Note that we can't hardcode size of
    // whole dialog to work correctly with different font size
    panel.setPreferredSize(new Dimension(375, 232));
    panel.setLayout(new BorderLayout());
    listView = new ListView();
    // proper border for the view
    listView.setBorder((Border)UIManager.get("Nb.ScrollPane.border")); // NOI18N
    listView.setPopupAllowed(false);
    listView.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DocumentsDlg.class, "ACSD_ListView"));
    //view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listView.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "closeSelected") ;//NOI18N
    listView.getActionMap().put( "closeSelected", new AbstractAction() {//NOI18N
        @Override
        public void actionPerformed( ActionEvent e ) {
            closeDocuments(e );
        }

    });
    panel.add(listView, BorderLayout.CENTER);
    return panel;
}
项目:routerapp    文件:MainWindow.java   
public void addLayout(GraphLayout lo) {
    try{
        final String name = lo.toString();
        final GraphLayout finalLo = lo;

        menu.addMenuItem(
                new AbstractAction(name) {
                    public void actionPerformed (ActionEvent evt) {
                        finalLo.setGraph(uiFacade.getGraph());
                        uiFacade.doGraphLayout(finalLo);
                    }
                },
                "Layouts",
                "",
                true
            );
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}
项目:incubator-netbeans    文件:SBOptionsPanel.java   
@NbBundle.Messages({
    "MSG_InvalidHome=Please, select a valid Scene Builder home...",
    "LBL_Browse=Browse..."
})
SBOptionsPanel(SBOptionsPanelController controller) {
    this.controller = controller;

    initComponents();

    sbHome.setNullSelectionMessage(Bundle.MSG_InvalidHome());
    sbHome.setGrowAction(new AbstractAction(Bundle.LBL_Browse()) {

        @Override
        public void actionPerformed(ActionEvent e) {
            browseAddNewRuntime();
        }
    });
    sbHomeInfo.setVisible(false);
}
项目:incubator-netbeans    文件:BookmarksView.java   
BookmarksView() {
//        getActionMap().put("rename", SystemAction.get(RenameAction.class));
        nodeTree = new BookmarksNodeTree();
        explorerManager = new ExplorerManager();
        explorerManager.setRootContext(nodeTree.rootNode());
        ActionMap actionMap = getActionMap();
        actionMap.put("delete", ExplorerUtils.actionDelete(explorerManager, false)); //NOI18N
        associateLookup(ExplorerUtils.createLookup(explorerManager, actionMap));
        explorerManager.addPropertyChangeListener(this);

        // Ctrl+T will toggle the tree/table view
        InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_DOWN_MASK), "toggle-view"); //NOI18N
        actionMap.put("toggle-view", new AbstractAction() { //NOI18N
            @Override
            public void actionPerformed(ActionEvent e) {
                setTreeViewVisible(!treeViewShowing);
            }
        });
        setIcon(ImageUtilities.loadImage("org/netbeans/modules/editor/bookmarks/resources/bookmark_16.png")); // NOI18N
    }
项目:ramus    文件:RowFindPanel.java   
/**
 * 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);
}
项目:incubator-netbeans    文件:ActionsTest.java   
public void testCheckPrioritiesOfIconsWithStringSmallIcon() {
    AbstractAction aa = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };
    Object icon = "org/openide/awt/TestIcon_big.png";
    aa.putValue(Action.SMALL_ICON, icon);
    aa.putValue("iconBase", "org/openide/awt/data/testIcon.gif");

    JButton b = new JButton();
    Actions.connect(b, aa);

    JMenuItem m = new JMenuItem();
    Actions.connect(m, aa, false);


    assertSame("Using the same icon (small" + icon, b.getIcon(), m.getIcon());
}
项目:incubator-netbeans    文件:TopComponentTest.java   
public void testCanTCGarbageCollectWhenActionInMap() {
    TopComponent tc = new TopComponent();
    class CAA extends AbstractAction implements
            ContextAwareAction {
        public void actionPerformed(ActionEvent arg0) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Action createContextAwareInstance(Lookup actionContext) {
            return this;
        }

    }
    ContextAwareAction del = new CAA();
    ContextAwareAction context = Actions.context(Integer.class, true, true, del, null, "DisplayName", null, true);
    Action a = context.createContextAwareInstance(tc.getLookup());
    tc.getActionMap().put("key", a);

    WeakReference<Object> ref = new WeakReference<Object>(tc);
    tc = null;
    a = null;
    del = null;
    context = null;
    assertGC("Can the component GC?", ref);
}
项目:incubator-netbeans    文件:TopComponentTest.java   
public void testCanTCGarbageCollectWhenActionInMapAndAssignLookup() {
    TopComponent tc = new TopComponent();
    class CAA extends AbstractAction implements
            ContextAwareAction {
        public void actionPerformed(ActionEvent arg0) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Action createContextAwareInstance(Lookup actionContext) {
            return this;
        }

    }
    tc.associateLookup(Lookups.fixed(tc.getActionMap(), tc));
    ContextAwareAction del = new CAA();
    ContextAwareAction context = Actions.context(Integer.class, true, true, del, null, "DisplayName", null, true);
    Action a = context.createContextAwareInstance(tc.getLookup());
    tc.getActionMap().put("key", a);

    WeakReference<Object> ref = new WeakReference<Object>(tc);
    tc = null;
    a = null;
    del = null;
    context = null;
    assertGC("Can the component GC?", ref);
}
项目:incubator-netbeans    文件:ProfilerTableActions.java   
private Action selectNextColumnAction() {
    return new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            ProfilerColumnModel cModel = table._getColumnModel();
            if (table.getRowCount() == 0 || cModel.getVisibleColumnCount() == 0) return;

            int column = table.getSelectedColumn();
            if (column == -1) {
                table.selectColumn(cModel.getFirstVisibleColumn(), false);
                table.selectRow(0, true);
            } else {
                int nextColumn = cModel.getNextVisibleColumn(column);
                if (nextColumn > column) table.selectColumn(nextColumn, true);
            }
        }
    };
}
项目:incubator-netbeans    文件:ProfilerTableActions.java   
private Action createNextCellAction() {
    return new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            ProfilerColumnModel cModel = table._getColumnModel();
            if (table.getRowCount() == 0 || cModel.getVisibleColumnCount() == 0) return;

            int column = table.getSelectedColumn();
            if (column == -1) {
                table.selectColumn(cModel.getFirstVisibleColumn(), false);
                table.selectRow(0, true);
            } else {
                int nextColumn = cModel.getNextVisibleColumn(column);
                boolean differentRow = nextColumn <= column && table.getRowCount() > 1;
                if (nextColumn != column) table.selectColumn(nextColumn, !differentRow);
                if (differentRow) {
                    int row = table.getSelectedRow();
                    int newRow = getNextRow(row);
                    if (row != newRow) table.selectRow(newRow, true);
                }
            }
        }
    };
}
项目:Cognizant-Intelligent-Test-Scripter    文件:JtableUtils.java   
/**
 * Adds input action map for the tmodel<p>
 * needed as <code>OnKeyPress Edit</code> in autosuggest overriding the
 * basic <code>Delete</code> key press
 *
 * @param table the target tmodel
 */
private static void clearTableSelectionOnDelete(final JTable table) {
    InputMap inputMap = table.getInputMap(WHEN_FOCUSED);
    ActionMap actionMap = table.getActionMap();
    inputMap.put(Keystroke.DELETE, "delete");
    actionMap.put("delete", new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelEditing(table);
            ClearSelection(table);
        }

    });
}
项目:incubator-netbeans    文件:KeyboardPopupSwitcher.java   
/**
 * Prevents showing a popup if a user releases the <code>releaseKey</code>
 * in time specified by <code>invokerTimer</code> (which is 200ms by
 * default).
 */
private static void processInterruption(KeyEvent kev) {
    int keyCode = kev.getKeyCode();
    if (keyCode == releaseKey && kev.getID() == KeyEvent.KEY_RELEASED) {
        // if an user releases Ctrl-Tab before the time to show
        // popup expires, don't show the popup at all and switch to
        // the last used document immediately
        cleanupInterrupter();
        hits = 0;
        AbstractAction rva = new ThreadsHistoryAction();
        rva.actionPerformed(new ActionEvent(kev.getSource(),
                ActionEvent.ACTION_PERFORMED,
                "immediately", kev.getModifiers())); // NOI18N
        kev.consume();
    // #88931: Need to react to KEY_PRESSED, not KEY_RELEASED, to not miss the hit    
    } else if (keyCode == triggerKey
            && kev.getModifiers() == InputEvent.CTRL_MASK
            && kev.getID() == KeyEvent.KEY_PRESSED) {
        // count number of trigger key hits before popup is shown
        hits++;
        kev.consume();
        cleanupInterrupter();
        instance = new KeyboardPopupSwitcher(hits + 1, true);
        instance.showPopup();
    }
}
项目:Cognizant-Intelligent-Test-Scripter    文件:TMSettingsControl.java   
private static AbstractAction getEncryptAction(final JTable table) {
    return new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent me) {
            try {
                int col = table.getSelectedColumn();
                int row = table.getSelectedRow();
                if (col > -1 && row > -1) {
                    String data = table.getValueAt(row, col).toString();
                    table.setValueAt(TMIntegration.encrypt(data), row, col);
                }
            } catch (HeadlessException ex) {
                Logger.getLogger(TMSettingsControl.class.getName())
                        .log(Level.SEVERE, ex.getMessage(), ex);
            }

        }
    };
}
项目:Cognizant-Intelligent-Test-Scripter    文件:SelectionManager.java   
private void init() {
    start = new Point(0, 0);
    end = new Point(0, 0);
    click = new Point(0, 0);
    selection = new Rectangle2D.Double();
    escape = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeSelection();
        }
    };
    com.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape");
    com.getActionMap().put("escape", escape);
    com.setFocusable(true);
    com.requestFocus();

}
项目:ramus    文件:AboutDialog.java   
public AboutDialog(JFrame frame, List<Plugin> plugins,
                   List<GUIPlugin> guiPlugins) {
    super(frame, true);
    this.setTitle(GlobalResourcesManager.getString("About"));
    this.plugins = plugins.subList(0, plugins.size());
    this.guiPlugins = guiPlugins;
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    JTabbedPane pane = new JTabbedPane();
    pane.addTab(GlobalResourcesManager.getString("About.MainTab"),
            createAboutComponent());
    pane.addTab(GlobalResourcesManager.getString("About.PluginList"),
            createPluginListComponent());
    pane.addTab(GlobalResourcesManager.getString("About.GUIPluginList"),
            createGUIPluginListComponent());

    pane.addTab(GlobalResourcesManager.getString("About.ThirdParts"),
            createThirdPartsComponnt());

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(pane, BorderLayout.CENTER);
    JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    bottomPanel.add(new JButton(new AbstractAction(GlobalResourcesManager
            .getString("ok")) {
        /**
         *
         */
        private static final long serialVersionUID = -8334150633007409370L;

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    }));
    panel.add(bottomPanel, BorderLayout.SOUTH);
    this.setContentPane(panel);
    setSize(600, 350);
    setResizable(false);
    setLocationRelativeTo(null);
}
项目:incubator-netbeans    文件:RuntimeComboBox.java   
RuntimeListModel() {
    this.growAction = new AbstractAction(otherSelectionMessage) {
        @Override
        public void actionPerformed(ActionEvent e) {
        }
    };
}
项目:incubator-netbeans    文件:LocationChooser.java   
public LocationChooser (LocationChooser.Panel firer) {
        super ();
        this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        this.setName (NbBundle.getMessage(LocationChooser.class,"TXT_PlatformFolderTitle"));
        this.setFileSelectionMode(DIRECTORIES_ONLY);
        this.setMultiSelectionEnabled(false);
        this.setControlButtonsAreShown(false);
//        this.accessory = new PlatformAccessory ();
        this.setFileFilter (new PlatformFileFilter());
//        this.setAccessory (this.accessory);
        this.firer = firer;
        this.platformFileView = new PlatformFileView( this.getFileSystemView());
        this.setFileView(this.platformFileView);
        this.addPropertyChangeListener (this);
        this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(LocationChooser.class,"AD_LocationChooser"));

        //XXX JFileChooser workaround
        getActionMap().put("cancel",
                new AbstractAction() {
                    public void actionPerformed(ActionEvent e) {
                        Container parent = LocationChooser.this.getParent();
                        do {
                            parent = parent.getParent();
                        } while (parent != null && !(parent instanceof Window));
                        if (parent != null) {
                            ((Window)parent).setVisible(false);
                        }
        }});
        getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put (KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
        this.setBorder(null);
    }
项目:QN-ACTR-Release    文件:JWatWizard.java   
public void setActionButton(String button, AbstractAction a) {
    for (JButton element : btnList) {
        try {
            if (element.getText().equals(button)) {
                a.putValue(Action.NAME, button);
                element.setAction(a);
                break;
            }
        } catch (ClassCastException e) {
            System.err.println("DEBUG: Casting not allowed");
        }
    }
}
项目:jdk8u-jdk    文件:RadialGradientPrintingTest.java   
public static void createUI() {
    f = new JFrame("RadialGradient Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final RadialGradientPrintingTest gpt = new RadialGradientPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);

    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);

    f.pack();
    f.setVisible(true);
}
项目:vexillo    文件:ExportDialog.java   
private static void setCancelButton(final JRootPane rp, final JButton b) {
    rp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
    rp.getActionMap().put("cancel", new AbstractAction() {
        private static final long serialVersionUID = 1L;
        public void actionPerformed(ActionEvent ev) {
            b.doClick();
        }
    });
}
项目:Logisim    文件:Caret.java   
Caret(HexEditor hex) {
    this.hex = hex;
    this.listeners = new ArrayList<ChangeListener>();
    this.cursor = -1;

    Listener l = new Listener();
    hex.addMouseListener(l);
    hex.addMouseMotionListener(l);
    hex.addKeyListener(l);
    hex.addFocusListener(l);

    InputMap imap = hex.getInputMap();
    ActionMap amap = hex.getActionMap();
    AbstractAction nullAction = new AbstractAction() {
        /**
         * 
         */
        private static final long serialVersionUID = 3859667024369145469L;

        @Override
        public void actionPerformed(ActionEvent e) {
        }
    };
    String nullKey = "null";
    amap.put(nullKey, nullAction);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), nullKey);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), nullKey);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), nullKey);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), nullKey);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), nullKey);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), nullKey);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), nullKey);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), nullKey);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), nullKey);
}
项目:incubator-netbeans    文件:VariablesSwitchViewAction.java   
public ViewAsMenuItem(final String type) {
    super(new AbstractAction(NbBundle.getMessage(NumericDisplayFilter.class, "CTL_View_"+type)) {
            @Override
            public void actionPerformed(ActionEvent e) {
                onViewAs(type, true);
            }
        });
}
项目:incubator-netbeans    文件:MainProjectScanningScope.java   
private void extractLabelsFromProject(Project p, Map<String, String> labels) {
    labels.clear();
    if( null == p ) {
        labels.put( Utils.KEY_STATUS_BAR_LABEL, 
                NbBundle.getMessage(MainProjectScanningScope.class, "LBL_NoProjectStatusBar") ); //NOI18N
    } else {
        ProjectInformation pi = ProjectUtils.getInformation(p);
            labels.put(AbstractAction.SHORT_DESCRIPTION, NbBundle.getMessage(MainProjectScanningScope.class, 
                    "HINT_CurrentProjectScope", pi.getDisplayName()) ); //NOI18N
            labels.put(AbstractAction.NAME, pi.getDisplayName());
            labels.put( Utils.KEY_STATUS_BAR_LABEL, 
                    NbBundle.getMessage(MainProjectScanningScope.class, "LBL_CurrentProjectStatusBar", pi.getDisplayName()) ); //NOI18N
    }
}
项目:incubator-netbeans    文件:CallbackSystemActionTest.java   
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);
    }
}