List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:ffx.ui.MainMenu.java
private JCheckBoxMenuItem addCBMenuItem(JMenu menu, String icon, String actionCommand, int mnemonic, int accelerator, final ActionListener actionListener) { final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(); Action a = new AbstractAction() { @Override/*w w w .j a v a 2 s .c o m*/ public void actionPerformed(ActionEvent e) { /** * If the ActionEvent is from a ToolBar button, pass it through * the JCheckBoxMenuItem. */ if (e.getSource() != menuItem) { menuItem.doClick(); return; } actionListener.actionPerformed(e); } }; configureAction(a, icon, actionCommand, mnemonic, accelerator); menuItem.setAction(a); menu.add(menuItem); return menuItem; }
From source file:ffx.ui.MainMenu.java
private JRadioButtonMenuItem addBGMI(ButtonGroup buttonGroup, JMenu menu, String icon, String actionCommand, int mnemonic, int accelerator, final ActionListener actionListener) { final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(); Action a = new AbstractAction() { @Override/*www. j a v a2 s . c o m*/ public void actionPerformed(ActionEvent e) { /** * If the ActionEvent is from a ToolBar button, pass it through * the JRadioButtonMenuItem. */ if (e.getSource() != menuItem) { menuItem.doClick(); return; } actionListener.actionPerformed(e); } }; this.configureAction(a, icon, actionCommand, mnemonic, accelerator); menuItem.setAction(a); buttonGroup.add(menuItem); menu.add(menuItem); return menuItem; }
From source file:com.openbravo.pos.sales.restaurant.JTicketsBagRestaurantRes.java
private void jButtonPlacesRemoveActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed JPlacesListDialog dialog = JPlacesListDialog.newJDialog(m_App, (JButton) evt.getSource()); PlaceSplit place2Remove = dialog.showPlacesList(placesReservation); if (place2Remove != null) { placesReservation.remove(place2Remove); RefreshPlaces();//from w w w . java 2 s. c o m m_Dirty.setDirty(true); } }
From source file:blue.automation.AutomationManager.java
private AutomationManager() { parameterActionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { if (data == null || selectedSoundLayer == null) { return; }/*from w w w. j a v a 2 s .c o m*/ JMenuItem menuItem = (JMenuItem) ae.getSource(); Parameter param = (Parameter) menuItem.getClientProperty("param"); parameterSelected(selectedSoundLayer, param); selectedSoundLayer = null; } }; renderTimeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { if (pce.getSource() == data) { if (pce.getPropertyName().equals("renderStartTime")) { updateValuesFromAutomations(); } } } }; }
From source file:de.adv_online.aaa.profiltool.ProfilDialog.java
public void actionPerformed(ActionEvent e) { if (startButton == e.getSource()) { startTransformation();//from www. ja v a 2 s . c o m } else if (e.getSource() == viewLogButton) { try { if (Desktop.isDesktopSupported()) Desktop.getDesktop().open(logfile); else if (SystemUtils.IS_OS_WINDOWS) Runtime.getRuntime().exec("cmd /c start " + logfile.getPath()); else Runtime.getRuntime().exec("open " + logfile.getPath()); } catch (IOException e1) { e1.printStackTrace(); System.exit(1); } } else if (e.getSource() == exitButton) { closeDialog(); } }
From source file:fll.subjective.SubjectiveFrame.java
/** * Set the tab and return behavior for a table. *//*from ww w.j a v a 2 s . c o m*/ private void setupTabReturnBehavior(final JTable table) { final InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // Have the enter key work the same as the tab key final KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); final KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); im.put(enter, im.get(tab)); // Override the default tab behavior // Tab to the next editable cell. When no editable cells goto next cell. final Action oldTabAction = table.getActionMap().get(im.get(tab)); final Action tabAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { if (null != oldTabAction) { oldTabAction.actionPerformed(e); } final JTable table = (JTable) e.getSource(); final int rowCount = table.getRowCount(); final int columnCount = table.getColumnCount(); int row = table.getSelectedRow(); int column = table.getSelectedColumn(); // skip the no show when tabbing while (!table.isCellEditable(row, column) || table.getColumnClass(column) == Boolean.class) { column += 1; if (column == columnCount) { column = 0; row += 1; } if (row == rowCount) { row = 0; } // Back to where we started, get out. if (row == table.getSelectedRow() && column == table.getSelectedColumn()) { break; } } table.changeSelection(row, column, false, false); } }; table.getActionMap().put(im.get(tab), tabAction); }
From source file:com.kenai.redminenb.query.RedmineQueryController.java
@Override public void actionPerformed(ActionEvent e) { try {//w w w . jav a 2 s . c om if (e.getSource() == queryPanel.searchButton) { onRefresh(); } else if (e.getSource() == queryPanel.gotoIssueButton) { onGotoIssue(); } else if (e.getSource() == queryPanel.saveChangesButton) { onSave(true); // refresh } else if (e.getSource() == queryPanel.cancelChangesButton) { onCancelChanges(); } else if (e.getSource() == queryPanel.webButton) { onWeb(); } else if (e.getSource() == queryPanel.saveButton) { onSave(false); // do not refresh } else if (e.getSource() == queryPanel.refreshButton) { onRefresh(); } else if (e.getSource() == queryPanel.modifyButton) { onModify(); } else if (e.getSource() == queryPanel.seenButton) { onMarkSeen(); } else if (e.getSource() == queryPanel.removeButton) { onRemove(); } else if (e.getSource() == queryPanel.refreshCheckBox) { onAutoRefresh(); } else if (e.getSource() == queryPanel.refreshConfigurationButton) { onRefreshConfiguration(); } else if (e.getSource() == queryPanel.findIssuesButton) { onFindIssues(); } else if (e.getSource() == queryPanel.cloneQueryButton) { onCloneQuery(); } else if (e.getSource() == queryPanel.issueIdTextField) { if (!queryPanel.issueIdTextField.getText().trim().equals("")) { // NOI18N onGotoIssue(); } } else if (e.getSource() == queryPanel.issueIdTextField || e.getSource() == queryPanel.queryTextField) { onRefresh(); } } catch (RedmineException ex) { Exceptions.printStackTrace(ex); } }
From source file:me.mayo.telnetkek.MainPanel.java
public final void setupTablePopup() { this.tblPlayers.addMouseListener(new MouseAdapter() { @Override/*from w w w .ja va2s.c o m*/ public void mouseReleased(final MouseEvent mouseEvent) { final JTable table = MainPanel.this.tblPlayers; final int r = table.rowAtPoint(mouseEvent.getPoint()); if (r >= 0 && r < table.getRowCount()) { table.setRowSelectionInterval(r, r); } else { table.clearSelection(); } final int rowindex = table.getSelectedRow(); if (rowindex < 0) { return; } if ((SwingUtilities.isRightMouseButton(mouseEvent) || mouseEvent.isControlDown()) && mouseEvent.getComponent() instanceof JTable) { final PlayerInfo player = getSelectedPlayer(); if (player != null) { final JPopupMenu popup = new JPopupMenu(player.getName()); final JMenuItem header = new JMenuItem("Apply action to " + player.getName() + ":"); header.setEnabled(false); popup.add(header); popup.addSeparator(); final ActionListener popupAction = (ActionEvent actionEvent) -> { Object _source = actionEvent.getSource(); if (_source instanceof PlayerListPopupItem_Command) { final PlayerListPopupItem_Command source = (PlayerListPopupItem_Command) _source; final String output = source.getCommand().buildOutput(source.getPlayer(), true); MainPanel.this.getConnectionManager().sendDelayedCommand(output, true, 100); } else if (_source instanceof PlayerListPopupItem) { final PlayerListPopupItem source = (PlayerListPopupItem) _source; final PlayerInfo _player = source.getPlayer(); switch (actionEvent.getActionCommand()) { case "Copy IP": { copyToClipboard(_player.getIp()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied IP to clipboard: " + _player.getIp())); break; } case "Copy Name": { copyToClipboard(_player.getName()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied name to clipboard: " + _player.getName())); break; } case "Copy UUID": { copyToClipboard(_player.getUuid()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied UUID to clipboard: " + _player.getUuid())); break; } } } }; TelnetKek.config.getCommands().stream().map( (command) -> new PlayerListPopupItem_Command(command.getName(), player, command)) .map((item) -> { item.addActionListener(popupAction); return item; }).forEach((item) -> { popup.add(item); }); popup.addSeparator(); JMenuItem item; item = new PlayerListPopupItem("Copy Name", player); item.addActionListener(popupAction); popup.add(item); item = new PlayerListPopupItem("Copy IP", player); item.addActionListener(popupAction); popup.add(item); item = new PlayerListPopupItem("Copy UUID", player); item.addActionListener(popupAction); popup.add(item); popup.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); } } } }); }
From source file:cpsViews.ParamsForm.java
private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed JComboBox convertBox = (JComboBox) evt.getSource(); String convertMethod = (String) convertBox.getSelectedItem(); if (null != convertMethod) switch (convertMethod) { case "Probkowanie": rodzajKonwersji = 1;/*www. ja v a2 s . com*/ signalName.setText(""); break; case "Kwantyzacja": rodzajKonwersji = 2; signalName.setText(""); break; case "Ekstrapolacja": rodzajKonwersji = 3; signalName.setText(""); break; case "Interpolacja": rodzajKonwersji = 4; signalName.setText(""); break; case "Rekonstrukcja_sinc": rodzajKonwersji = 5; signalName.setText(""); break; } }
From source file:Citas.FrameCita.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == agregarB) { try {/*w w w . j a v a 2 s . c om*/ //Cita JSONObject cita = new JSONObject(); cita.put("fecha", fechaJ.getText()); cita.put("hora", horaJ.getText()); cita.put("paciente", 3); cita.put("medicos", "1"); cita.put("tratamiento", "tratamiento"); cita.put("diagnostico", "diagnostico"); cita.put("motivo", motivosTA.getText()); System.out.print(cita); //Paciente JSONObject paciente = new JSONObject(); paciente.put("cedula", cedulaJ.getText()); paciente.put("nombre", nombreJ.getText()); paciente.put("apellido", apellidoJ.getText()); paciente.put("direccion", direccionJ.getText()); paciente.put("correo", correoJ.getText()); paciente.put("tlfncasa", telefonoCasaJ.getText()); paciente.put("tlfncelular", telefonoCelularJ.getText()); System.out.print(paciente); //rutasAdd.add("http://localhost/API_Citas/public/Pacientes/insertarPaciente", paciente); rutasAdd.add("http://localhost/API_Citas/public/Citas/insertarCita", cita); setCitas(); } catch (IOException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (JSONException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (ParseException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (java.text.ParseException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } return; } if (e.getSource() == modificarB) { return; } if (e.getSource() == eliminarB) { return; } if (e.getSource() == atrasB) { } if (e.getSource() == buscarB) { String[] opciones = { "Aceptar" }; int opcion = JOptionPane.showOptionDialog(null //componente , "Cedula no pertenece a ningun paciente registrado" // Mensaje , "Paciente no encontrado" // Titulo en la barra del cuadro , JOptionPane.DEFAULT_OPTION // Tipo de opciones , JOptionPane.WARNING_MESSAGE // Tipo de mensaje (icono) , null // Icono (ninguno) , opciones // Opciones personalizadas , null // Opcion por defecto ); } }