List of usage examples for java.awt.event ActionEvent ActionEvent
public ActionEvent(Object source, int id, String command)
From source file:org.jdal.swing.Selector.java
/** * Notify listeners that selected values changes *//*from w ww . j a v a 2 s . c om*/ protected void fireActionEvent() { if (!firingActionEvent) { firingActionEvent = true; ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "selectorChanged"); for (ActionListener listener : listenerList.getListeners(ActionListener.class)) listener.actionPerformed(event); firingActionEvent = false; } }
From source file:net.sf.jabref.gui.FileListEntryEditor.java
public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showProgressBar, boolean showOpenButton, BibDatabaseContext databaseContext) { this.entry = entry; this.databaseContext = databaseContext; ActionListener okAction = e -> { // If OK button is disabled, ignore this event: if (!ok.isEnabled()) { return; }/*from w ww . j ava2 s . c om*/ // If necessary, ask the external confirm object whether we are ready to close. if (externalConfirm != null) { // Construct an updated FileListEntry: storeSettings(entry); if (!externalConfirm.confirmClose(entry)) { return; } } diag.dispose(); storeSettings(FileListEntryEditor.this.entry); okPressed = true; }; types = new JComboBox<>(); types.addItemListener(itemEvent -> { if (!okDisabledExternally) { ok.setEnabled(types.getSelectedItem() != null); } }); FormBuilder builder = FormBuilder.create().layout(new FormLayout( "left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p")); builder.add(Localization.lang("Link")).xy(1, 1); builder.add(link).xy(3, 1); final BrowseListener browse = new BrowseListener(frame, link); final JButton browseBut = new JButton(Localization.lang("Browse")); browseBut.addActionListener(browse); builder.add(browseBut).xy(5, 1); JButton open = new JButton(Localization.lang("Open")); if (showOpenButton) { builder.add(open).xy(7, 1); } builder.add(Localization.lang("Description")).xy(1, 3); builder.add(description).xyw(3, 3, 3); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); builder.add(Localization.lang("File type")).xy(1, 5); builder.add(types).xyw(3, 5, 3); if (showProgressBar) { builder.appendRows("2dlu, p"); builder.add(downloadLabel).xy(1, 7); builder.add(prog).xyw(3, 7, 3); } ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addRelatedGap(); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); ok.addActionListener(okAction); // Add OK action to the two text fields to simplify entering: link.addActionListener(okAction); description.addActionListener(okAction); open.addActionListener(e -> openFile()); AbstractAction cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { diag.dispose(); } }; cancel.addActionListener(cancelAction); // Key bindings: ActionMap am = builder.getPanel().getActionMap(); InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelAction); link.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { checkExtension(); } @Override public void removeUpdate(DocumentEvent documentEvent) { // Do nothing } @Override public void changedUpdate(DocumentEvent documentEvent) { checkExtension(); } }); diag = new JDialog(frame, Localization.lang("Save file"), true); diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); diag.pack(); diag.setLocationRelativeTo(frame); diag.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent event) { if (openBrowseWhenShown && !dontOpenBrowseUntilDisposed) { dontOpenBrowseUntilDisposed = true; SwingUtilities.invokeLater(() -> browse.actionPerformed(new ActionEvent(browseBut, 0, ""))); } } @Override public void windowClosed(WindowEvent event) { dontOpenBrowseUntilDisposed = false; } }); setValues(entry); }
From source file:ryerson.daspub.ui.ApplicationJFrame.java
/** * Handle window closing event.//from w w w . ja va 2s.com * @param evt Window event */ private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing ExitAction a = new ExitAction(); ActionEvent e = new ActionEvent(this, 0, ""); a.actionPerformed(e); }
From source file:net.sf.mzmine.modules.visualization.neutralloss.NeutralLossPlot.java
/** * @see org.jfree.chart.event.ChartProgressListener#chartProgress(org.jfree.chart.event.ChartProgressEvent) *//*from www.j a v a 2s.c o m*/ public void chartProgress(ChartProgressEvent event) { super.chartProgress(event); if (event.getType() == ChartProgressEvent.DRAWING_FINISHED) { visualizer.updateTitle(); if (showSpectrumRequest) { showSpectrumRequest = false; visualizer.actionPerformed( new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM")); } } }
From source file:inflor.core.plots.FCSChartPanel.java
public void activateGateSelectButton() { ActionListener[] action = selectionButton.getActionListeners(); for (ActionListener act : action) { if (act instanceof SelectionButtonListener) { ActionEvent event = new ActionEvent(selectionButton, 42, "What was the question again?"); act.actionPerformed(event);// w w w. j a va 2 s .c o m } } }
From source file:com.sshtools.common.ui.SshToolsApplicationApplet.java
/** * * * @param name//from w ww.ja va 2 s. c o m */ public void doAction(String name) { StandardAction a = applicationPanel.getAction(name); if (a != null) { if (a.isEnabled()) { log.debug("Performing action " + a.getName()); a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, a.getActionCommand())); } else { log.warn("No performing action '" + a.getName() + "' because it is disabled."); } } else { log.error("No action named " + name); } }
From source file:org.apache.jmeter.JMeterReport.java
public void startGui(CLOption testFile) { PluginManager.install(this, true); ReportTreeModel treeModel = new ReportTreeModel(); ReportTreeListener treeLis = new ReportTreeListener(treeModel); treeLis.setActionHandler(ReportActionRouter.getInstance()); ReportGuiPackage.getInstance(treeLis, treeModel); org.apache.jmeter.gui.ReportMainFrame main = new org.apache.jmeter.gui.ReportMainFrame(treeModel, treeLis); ComponentUtil.centerComponentInWindow(main, 80); main.setVisible(true);/*from ww w .j av a 2s. c o m*/ ReportActionRouter.getInstance().actionPerformed(new ActionEvent(main, 1, ReportCheckDirty.ADD_ALL)); if (testFile != null) { FileInputStream reader = null; try { File f = new File(testFile.getArgument()); log.info("Loading file: " + f); reader = new FileInputStream(f); HashTree tree = SaveService.loadTree(reader); ReportGuiPackage.getInstance().setReportPlanFile(f.getAbsolutePath()); new ReportLoad().insertLoadedTree(1, tree); } catch (Exception e) { log.error("Failure loading test file", e); JMeterUtils.reportErrorToUser(e.toString()); } finally { JOrphanUtils.closeQuietly(reader); } } }
From source file:com.microsoft.alm.plugin.idea.common.ui.common.tabs.TabFormImpl.java
/** * Create the feedback portion of the toolbar * * @return feedback toolbar/* ww w .j a v a 2 s. c om*/ */ protected DefaultActionGroup createFeedbackGroup() { final AnAction sendFeedback = new AnAction(TfPluginBundle.message(TfPluginBundle.KEY_FEEDBACK_DIALOG_TITLE), TfPluginBundle.message(TfPluginBundle.KEY_FEEDBACK_DIALOG_TITLE), Icons.Smile) { @Override public void actionPerformed(AnActionEvent anActionEvent) { final FeedbackAction action = new FeedbackAction(anActionEvent.getProject(), TfPluginBundle.message(tabTitle)); action.actionPerformed(new ActionEvent(anActionEvent.getInputEvent().getSource(), anActionEvent.getInputEvent().getID(), CMD_SEND_FEEDBACK)); } }; return new DefaultActionGroup(sendFeedback); }
From source file:com.funambol.foundation.admin.SIFSyncSourceConfigPanel.java
/** * Create the panel/* w w w .j av a 2 s .com*/ * * @throws Exception if error occures during creation of the panel */ private void init() { this.setLayout(null); // // Set properties of label, position and border referred to the title //of the panel // titledBorder1 = new TitledBorder(""); panelName.setFont(titlePanelFont); panelName.setText("Edit SIF SyncSource"); panelName.setBounds(new Rectangle(14, 5, 316, 28)); panelName.setAlignmentX(SwingConstants.CENTER); panelName.setBorder(titledBorder1); int y = 60; int dy = 30; int x1 = 14; int x2 = 170; int w1 = 150; int w2 = 350; int h = 18; sourceUriLabel.setText("Source URI: "); sourceUriLabel.setFont(defaultFont); sourceUriLabel.setBounds(x1, y, w1, h); sourceUriValue.setFont(defaultFont); sourceUriValue.setBounds(x2, y, w2, h); y += dy; nameLabel.setText("Name: "); nameLabel.setFont(defaultFont); nameLabel.setBounds(x1, y, w1, h); nameValue.setFont(defaultFont); nameValue.setBounds(x2, y, w2, h); y += dy; typeLabel.setText("Type: "); typeLabel.setFont(defaultFont); typeLabel.setBounds(x1, y, w1, h); typeCombo.setFont(defaultFont); typeCombo.setBounds(x2, y, 100, h); typeCombo.addItem(TYPE_SIF_C); typeCombo.addItem(TYPE_SIF_E); typeCombo.addItem(TYPE_SIF_N); typeCombo.addItem(TYPE_SIF_T); typeCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { handleTypeSelected(); } }); handleTypeSelected(); y += dy; directoryLabel.setText("Source Directory: "); directoryLabel.setFont(defaultFont); directoryLabel.setBounds(x1, y, w1, h); directoryValue.setFont(defaultFont); directoryValue.setBounds(x2, y, w2, h); y += dy; twinPropertiesLabel.setText("Twin properties: "); twinPropertiesLabel.setFont(defaultFont); twinPropertiesLabel.setBounds(x1, y, w1, h); descrTwinPropLabel.setText("(Used to identify twins)"); descrTwinPropLabel.setFont(defaultFont); descrTwinPropLabel.setBounds(x1, (y + 15), w1, h); twinPropertiesValue.setFont(defaultFont); twinPropertiesValue.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); twinPropertiesValue.setAutoscrolls(true); scrollTable = new JScrollPane(twinPropertiesValue); scrollTable.setWheelScrollingEnabled(true); scrollTable.setBounds(x2, y, 200, 66); scrollTable.setColumnHeader(null); scrollTable.setMinimumSize(new Dimension(200, 66)); scrollTable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); y += 45; y += dy; multiUserLabel.setText("MultiUser: "); multiUserLabel.setFont(defaultFont); multiUserLabel.setBounds(x1, y, w1, h); multiUserValue.setSelected(false); multiUserValue.setBounds(x2, y, h, h); y += 5; y += dy; confirmButton.setFont(defaultFont); confirmButton.setText("Add"); confirmButton.setBounds(x2, y, 70, 25); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); if (getState() == STATE_INSERT) { SIFSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(SIFSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand())); } else { SIFSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(SIFSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); // // Add all components to the panel // this.add(panelName, null); this.add(sourceUriLabel, null); this.add(sourceUriValue, null); this.add(nameLabel, null); this.add(nameValue, null); this.add(typeLabel, null); this.add(typeCombo, null); this.add(directoryLabel, null); this.add(directoryValue, null); this.add(twinPropertiesLabel, null); this.add(scrollTable, null); this.add(descrTwinPropLabel, null); this.add(multiUserLabel, null); this.add(multiUserValue, null); this.add(confirmButton, null); }
From source file:uk.co.modularaudio.componentdesigner.ComponentDesigner.java
public void registerCloseAction() throws DatastoreException { mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); mainFrame.addWindowListener(new WindowListener() { @Override/*from w w w . j a v a 2s .c o m*/ public void windowClosed(final WindowEvent e) { log.debug("Window closed event received"); } @Override public void windowOpened(final WindowEvent e) { try { log.debug("Window opening event received - setting thread to lowest priority."); ThreadUtils.setCurrentThreadPriority(MAThreadPriority.APPLICATION); if (log.isDebugEnabled()) { log.debug("Now set to " + MAThreadPriority.APPLICATION); } } catch (final Exception ie) { final String msg = "Exception caught setting gui thread priority: " + ie.toString(); log.error(msg, ie); } } @Override public void windowClosing(final WindowEvent e) { log.debug("Window closing event received."); final Action exitAction = mainFrameActions.getExitAction(); final ActionEvent exitActionEvent = new ActionEvent(e.getSource(), e.getID(), ""); exitAction.actionPerformed(exitActionEvent); } @Override public void windowIconified(final WindowEvent e) { } @Override public void windowDeiconified(final WindowEvent e) { } @Override public void windowActivated(final WindowEvent e) { } @Override public void windowDeactivated(final WindowEvent e) { } }); }