List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction()
From source file:org.nekorp.workflow.desktop.view.CostoServicioView.java
private void setShorcuts() { InputMap im = tablaCostos.getInputMap(JTable.WHEN_FOCUSED); ActionMap am = tablaCostos.getActionMap(); Action deleteAction = new AbstractAction() { @Override/*from w ww. ja va 2 s .c om*/ public void actionPerformed(ActionEvent e) { borrarActionPerformed(e); } }; im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Delete"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "Delete"); am.put("Delete", deleteAction); Action addAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { borrarActionPerformed(e); } }; im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), "Add"); am.put("Add", addAction); }
From source file:gda.gui.scanplot.ScanPlot.java
private void jbInit() { this.setRequestFocusEnabled(true); legendVisible.setMnemonic(KeyEvent.VK_M); legendVisible.setSelected(false);/* w ww. j av a2 s. c o m*/ legendVisible.setToolTipText("Show the legend"); legendVisible.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { hideLegend(!((JMenuItem) e.getSource()).isSelected()); } }); { if (plot instanceof ChartPanel && legendPanel instanceof Component) { ((ChartPanel) plot).setMinimumDrawWidth(10); ((ChartPanel) plot).setMinimumDrawHeight(150); ((Component) plot).setPreferredSize(new Dimension(800, 500)); ((Component) legendPanel).setPreferredSize(new Dimension(100, 500)); setLayout(new BorderLayout()); legendVisible.setSelected(true); } hideLegend(false); } }
From source file:org.freeplane.core.ui.components.OptionalDontShowMeAgainDialog.java
private OptionalDontShowMeAgainDialog show() { final String property = getProperty(); if (StringUtils.equals(property, "true")) { mResult = JOptionPane.OK_OPTION; return this; }//from w w w . j ava2s . c o m if (mMessageType == BOTH_OK_AND_CANCEL_OPTIONS_ARE_STORED && StringUtils.equals(property, "false")) { mResult = JOptionPane.CANCEL_OPTION; return this; } mDialog = null; mDialog = new JDialog(mParent, TextUtils.getText(mTitleId)); mDialog.setModal(true); mDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); final AbstractAction cancelAction = new AbstractAction() { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent pE) { close(JOptionPane.CANCEL_OPTION); } }; final AbstractAction okAction = new AbstractAction() { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent pE) { close(JOptionPane.OK_OPTION); } }; UITools.addEscapeActionToDialog(mDialog, cancelAction); mDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent pE) { close(JOptionPane.CANCEL_OPTION); } }); mDialog.getContentPane().setLayout(new GridBagLayout()); mDialog.getContentPane().add(new JLabel(TextUtils.getText(mMessageId)), new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0)); final ImageIcon questionMark; if (mMessageType == ONLY_OK_SELECTION_IS_SHOWN) { questionMark = new ImageIcon( ResourceController.getResourceController().getResource("/images/icons/messagebox_warning.png")); } else { questionMark = new ImageIcon( ResourceController.getResourceController().getResource("/images/icons/help.png")); } mDialog.getContentPane().add(new JLabel(questionMark), new GridBagConstraints(0, 0, 1, 2, 1.0, 2.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0)); String boxString; if (mMessageType != OptionalDontShowMeAgainDialog.BOTH_OK_AND_CANCEL_OPTIONS_ARE_STORED) { boxString = "OptionalDontShowMeAgainDialog.dontShowAgain"; } else { boxString = "OptionalDontShowMeAgainDialog.rememberMyDescision"; } mDontShowAgainBox = new JCheckBox(TextUtils.getRawText(boxString)); MenuBuilder.setLabelAndMnemonic(mDontShowAgainBox, null); mDialog.getContentPane().add(mDontShowAgainBox, new GridBagConstraints(0, 2, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0)); final String okText; if (mMessageType == ONLY_OK_SELECTION_IS_SHOWN) { okText = TextUtils.getRawText("ok"); } else { okText = TextUtils.getRawText("OptionalDontShowMeAgainDialog.ok"); } final JButton okButton = new JButton(okText); MenuBuilder.setLabelAndMnemonic(okButton, null); okButton.addActionListener(okAction); mDialog.getContentPane().add(okButton, new GridBagConstraints(2, 3, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0)); if (mMessageType != ONLY_OK_SELECTION_IS_SHOWN) { final JButton cancelButton = new JButton(TextUtils.getRawText("OptionalDontShowMeAgainDialog.cancel")); MenuBuilder.setLabelAndMnemonic(cancelButton, null); cancelButton.addActionListener(cancelAction); mDialog.getContentPane().add(cancelButton, new GridBagConstraints(3, 3, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0)); } mDialog.getRootPane().setDefaultButton(okButton); mDialog.pack(); if (mNode != null) { UITools.setDialogLocationRelativeTo(mDialog, mNode); } else { mDialog.setLocationRelativeTo(null); } mDialog.setVisible(true); return this; }
From source file:de.tor.tribes.ui.views.DSWorkbenchConquersFrame.java
DSWorkbenchConquersFrame() { initComponents();//w w w . j av a 2s . co m centerPanel = new GenericTestPanel(); jConquerPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jConquersPanel); buildMenu(); jConquersFrameAlwaysOnTop .setSelected(GlobalOptions.getProperties().getBoolean("conquers.frame.alwaysOnTop")); setAlwaysOnTop(jConquersFrameAlwaysOnTop.isSelected()); jConquersTable.setModel(new ConquerTableModel()); jConquersTable.getSelectionModel().addListSelectionListener(DSWorkbenchConquersFrame.this); capabilityInfoPanel1.addActionListener(this); jConquersTable.getActionMap().put("find", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { DSWorkbenchConquersFrame.getSingleton().actionPerformed(new ActionEvent(jConquersTable, 0, "Find")); } }); jXColumnList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateFilter(); } }); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.conquers_view", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> setGlassPane(jxFilterPane); pack(); }
From source file:storybook.ui.chart.AbstractChartPanel.java
private AbstractAction getExportAction() { if (this.exportAction == null) { this.exportAction = new AbstractAction() { @Override//from w w w. j a v a2s . c om public void actionPerformed(ActionEvent paramAnonymousActionEvent) { try { Internal localInternal = BookUtil.get(AbstractChartPanel.this.mainFrame, SbConstants.BookKey.EXPORT_DIRECTORY, EnvUtil.getDefaultExportDir(AbstractChartPanel.this.mainFrame)); File localFile1 = new File(localInternal.getStringValue()); JFileChooser localJFileChooser = new JFileChooser(localFile1); localJFileChooser.setFileFilter(new PngFileFilter()); localJFileChooser.setApproveButtonText(I18N.getMsg("msg.common.export")); String str = AbstractChartPanel.this.mainFrame.getDbFile().getName() + " - " + AbstractChartPanel.this.chartTitle; str = IOUtil.cleanupFilename(str); localJFileChooser.setSelectedFile(new File(str)); int i = localJFileChooser.showDialog(AbstractChartPanel.this.getThis(), I18N.getMsg("msg.common.export")); if (i == 1) { return; } File localFile2 = localJFileChooser.getSelectedFile(); if (!localFile2.getName().endsWith(".png")) { localFile2 = new File(localFile2.getPath() + ".png"); } ScreenImage.createImage(AbstractChartPanel.this.panel, localFile2.toString()); JOptionPane.showMessageDialog(AbstractChartPanel.this.getThis(), I18N.getMsg("msg.common.export.success"), I18N.getMsg("msg.common.export"), 1); } catch (HeadlessException | IOException localException) { } } }; } return this.exportAction; }
From source file:de.tor.tribes.ui.views.DSWorkbenchTagFrame.java
/** Creates new form DSWorkbenchTagFrame */ DSWorkbenchTagFrame() {/*from www . ja v a2s .com*/ initComponents(); centerPanel = new GenericTestPanel(); jTagPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jTagsPanel); buildMenu(); capabilityInfoPanel1.addActionListener(this); jTagsTable.setModel(new TagTableModel()); jTagsTable.getSelectionModel().addListSelectionListener(DSWorkbenchTagFrame.this); jTagsTable.getActionMap().put("find", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { //ignore find } }); KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false); KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false); KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false); jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "BBCopy", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jVillageList.registerKeyboardAction(DSWorkbenchTagFrame.this, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jVillageList.registerKeyboardAction(DSWorkbenchTagFrame.this, "BBCopy_Village", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "Paste", paste, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.tag_view", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> initialize(); pack(); }
From source file:org.jets3t.gui.ProgressDialog.java
private void initGui() { // Initialise skins factory. skinsFactory = SkinsFactory.getInstance(applicationProperties); // Set Skinned Look and Feel. LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel"); try {/* ww w.j a v a 2 s. c o m*/ UIManager.setLookAndFeel(lookAndFeel); } catch (UnsupportedLookAndFeelException e) { log.error("Unable to set skinned LookAndFeel", e); } this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); this.setResizable(true); JPanel container = new JPanel(new GridBagLayout()); statusMessageLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressDialogStatusMessageLabel"); statusMessageLabel.setText(" "); statusMessageLabel.setHorizontalAlignment(JLabel.CENTER); container.add(statusMessageLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); progressBar = skinsFactory.createSkinnedJProgressBar("ProgressDialogProgressBar", 0, 100); progressBar.setPreferredSize(new Dimension(550, 20)); container.add(progressBar, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); detailsTextLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressDialogDetailedMessageLabel"); detailsTextLabel.setText(" "); detailsTextLabel.setHorizontalAlignment(JLabel.CENTER); container.add(detailsTextLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Display the cancel button if a cancel event listener is available. cancelButton = skinsFactory.createSkinnedJButton("ProgressDialogCancelButton"); cancelButton.setText("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); cancelButton.setDefaultCapable(true); container.add(cancelButton, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Set Cancel as the default operation when ESCAPE is pressed. this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = 4397881858674185924L; public void actionPerformed(ActionEvent actionEvent) { cancelButton.doClick(); } }); this.getContentPane().add(container); this.pack(); this.setLocationRelativeTo(this.getOwner()); }
From source file:org.notebook.gui.widget.GuiUtils.java
/** * Adds the dispose action with escape key. * /*from w w w . j a v a 2s . c o m*/ * @param dialog * the dialog */ public static void addDisposeActionWithEscapeKey(final JDialog dialog) { // Handle escape key to close the dialog KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); Action disposeAction = new AbstractAction() { private static final long serialVersionUID = 0L; @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE"); dialog.getRootPane().getActionMap().put("ESCAPE", disposeAction); }
From source file:org.interreg.docexplore.management.manage.ManageComponent.java
@SuppressWarnings("serial") public ManageComponent(MainWindow win, final ManageHandler handler, boolean editable, boolean showPages) { super(new BorderLayout()); this.win = win; this.handler = handler; this.bookList = new JList(new CollectionNode(this)); setBorder(BorderFactory.createLineBorder(Color.black, 1)); bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bookList.setCellRenderer(new ManageCellRenderer()); //tree.setRowHeight(52); add(new JScrollPane(bookList), BorderLayout.CENTER); if (editable) { bookList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { int index = bookList.locationToIndex(e.getPoint()); if (index < 0 || !bookList.getCellBounds(index, index).contains(e.getPoint())) return; handler.bookOpened((Book) bookList.getModel().getElementAt(index)); }//from w ww.j a va 2s . c o m } }); this.toolbar = new ManageToolbar(this); add(toolbar, BorderLayout.NORTH); bookList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; int count = bookList.getSelectedIndices().length; toolbar.deleteButton.setEnabled(count > 0); toolbar.editButton.setEnabled(count == 1); // toolbar.processButton.setEnabled(count == 1); toolbar.exportButton.setEnabled(count == 1); } }); } bookList.setBackground(new JPanel().getBackground()); getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DEL"); getActionMap().put("DEL", new AbstractAction() { public void actionPerformed(ActionEvent arg0) { @SuppressWarnings({ "unchecked", "rawtypes" }) Vector<Book> books = new Vector(Arrays.asList(bookList.getSelectedValues())); if (books.size() > 0 && handler.booksDeleted(books)) { ((CollectionNode) bookList.getModel()).reload(); bookList.clearSelection(); bookList.repaint(); } } }); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.StartupDialog.java
/** * Initialises all GUI elements./*w w w.jav a2s. com*/ */ private void initGui() { this.setResizable(false); this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); cancelButton = new JButton("Don't log in"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); storeCredentialsButton = new JButton("Store Credentials"); storeCredentialsButton.setActionCommand("StoreCredentials"); storeCredentialsButton.addActionListener(this); okButton = new JButton("Log in"); okButton.setActionCommand("LogIn"); okButton.addActionListener(this); // Set default ENTER and ESCAPE buttons. this.getRootPane().setDefaultButton(okButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -1742280851624947873L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); JPanel buttonsPanel = new JPanel(new GridBagLayout()); buttonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(storeCredentialsButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(okButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); loginPassphrasePanel = new LoginPassphrasePanel(hyperlinkListener); loginLocalFolderPanel = new LoginLocalFolderPanel(ownerFrame, hyperlinkListener); loginCredentialsPanel = new LoginCredentialsPanel(false, hyperlinkListener); // Tabbed Pane. tabbedPane = new JTabbedPane(); tabbedPane.addChangeListener(this); tabbedPane.add(loginPassphrasePanel, "S3 Online"); tabbedPane.add(loginLocalFolderPanel, "Local Folder"); tabbedPane.add(loginCredentialsPanel, "Direct Login"); int row = 0; this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(tabbedPane, new GridBagConstraints(0, row++, 2, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); this.pack(); this.setSize(500, 400); this.setLocationRelativeTo(this.getOwner()); }