List of usage examples for java.awt.event ActionEvent getActionCommand
public String getActionCommand()
From source file:ContainerEventDemo.java
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (ADD.equals(command)) { JButton newButton = new JButton("JButton #" + (buttonList.size() + 1)); buttonList.addElement(newButton); buttonPanel.add(newButton);/*from www. ja v a 2s .c om*/ buttonPanel.revalidate(); // Make the button show up. } else if (REMOVE.equals(command)) { int lastIndex = buttonList.size() - 1; try { JButton nixedButton = buttonList.elementAt(lastIndex); buttonPanel.remove(nixedButton); buttonList.removeElementAt(lastIndex); buttonPanel.revalidate(); // Make the button disappear. buttonPanel.repaint(); // Make the button disappear. } catch (ArrayIndexOutOfBoundsException exc) { } } else if (CLEAR.equals(command)) { display.setText(""); } }
From source file:br.com.elotech.sits.config.dialog.ChooseFileDialog.java
@Override public void actionPerformed(ActionEvent e) { logger.info(e);// w w w . ja v a2 s . c o m if (e.getActionCommand().equals("CancelSelection")) { setVisible(false); } else { if ((!fileChooser.getSelectedFile().isDirectory()) || (option == ChooseOption.FOLDER)) { select(); } } }
From source file:net.femtoparsec.jwhois.gui.JWhoIsQueryGUI.java
@Override public void actionPerformed(ActionEvent e) { if (QUERY_FIELD_ACTION_NAME.equals(e.getActionCommand())) { final String query = this.queryField.getText(); this.queryButton.setEnabled(!StringUtils.isEmpty(query)); this.model.setQuery(query); } else if (QUERY_BUTTON_ACTION_NAME.equals(e.getActionCommand())) { final String query = this.queryField.getText(); this.model.setQuery(query); this.queryButton.setEnabled(false); new Thread(new Runnable() { @Override//from w ww. j a va2 s.c om public void run() { model.launchQuery(); } }).start(); } }
From source file:QandE.Flipper2.java
public void actionPerformed(ActionEvent e) { //Only two buttons: if not "Start" then "Stop" boolean startMode = e.getActionCommand().equals("Start"); startButton.setEnabled(!startMode);// w w w . ja va 2s . co m stopButton.setEnabled(startMode); if (startMode) { flipTask = new FlipTask(); flipTask.execute(); } else { flipTask.cancel(true); flipTask = null; } }
From source file:com.github.woonsan.commons.scxml.examples.stopwatch.StopWatchFrame.java
public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); try {/*from w w w . ja va 2s . c o m*/ if ("START".equals(command)) { executor.triggerEvent(new TriggerEvent("watch.start", TriggerEvent.SIGNAL_EVENT)); startButton.setEnabled(false); stopButton.setEnabled(true); resetButton.setEnabled(false); } else if ("STOP".equals(command)) { executor.triggerEvent(new TriggerEvent("watch.stop", TriggerEvent.SIGNAL_EVENT)); startButton.setEnabled(true); stopButton.setEnabled(false); resetButton.setEnabled(true); } else if ("RESET".equals(command)) { executor.triggerEvent(new TriggerEvent("watch.reset", TriggerEvent.SIGNAL_EVENT)); startButton.setEnabled(true); stopButton.setEnabled(false); resetButton.setEnabled(false); } } catch (ModelException e) { e.printStackTrace(); } }
From source file:ContainerEventDemo.java
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (ADD.equals(command)) { JButton newButton = new JButton("JButton #" + (buttonList.size() + 1)); buttonList.addElement(newButton); buttonPanel.add(newButton);/*w w w . j ava 2 s . co m*/ buttonPanel.revalidate(); //Make the button show up. } else if (REMOVE.equals(command)) { int lastIndex = buttonList.size() - 1; try { JButton nixedButton = (JButton) buttonList.elementAt(lastIndex); buttonPanel.remove(nixedButton); buttonList.removeElementAt(lastIndex); buttonPanel.revalidate(); //Make the button disappear. buttonPanel.repaint(); //Make the button disappear. } catch (ArrayIndexOutOfBoundsException exc) { } } else if (CLEAR.equals(command)) { display.setText(""); } }
From source file:MainClass.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Audio")) { String soundName = getParameter("audio"); if (soundName != null) { AudioClip ac = getAudioClip(getDocumentBase(), soundName); ac.play();// w w w . j a va 2 s. c o m } return; } try { URL u = new URL("http://www.java2s.com"); getAppletContext().showDocument(u); } catch (MalformedURLException exc) { System.out.println(e); } }
From source file:com.experiments.DynamicDataDemo.java
/** * Handles a click on the button by adding new (random) data. * /*ww w . ja v a2s . c o m*/ * @param e * the action event. */ public void actionPerformed(final ActionEvent e) { if (e.getActionCommand().equals("ADD_DATA")) { final double factor = 0.90 + 0.2 * Math.random(); this.lastValue = this.lastValue * factor; final Millisecond now = new Millisecond(); System.out.println("Now = " + now.toString()); this.series.add(new Millisecond(), this.lastValue); } else if (e.getActionCommand().equals("START_ADDING")) { if (timer == null) { timer = new Timer(interval, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final double factor = 0.90 + 0.2 * Math.random(); DynamicDataDemo.this.lastValue = DynamicDataDemo.this.lastValue * factor; final Millisecond now = new Millisecond(); System.out.println("Now = " + now.toString()); DynamicDataDemo.this.series.add(new Millisecond(), DynamicDataDemo.this.lastValue); } }); timer.start(); } } else if (e.getActionCommand().equals("STOP_ADDING")) { if (timer != null) { timer.stop(); } timer = null; } }
From source file:it.unibas.spicygui.controllo.provider.MyPopupProviderJoinCondition.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(DELETE)) { StatusDisplayer.getDefault()/*w ww. ja v a 2 s. c om*/ .setStatusText(NbBundle.getMessage(Costanti.class, Costanti.GENERIC_DELETE)); deleteAll(); } else if (e.getActionCommand().equals(TOGGLE_MANDATORY)) { toggleMandatory(); } else if (e.getActionCommand().equals(TOGGLE_FOREIGN)) { toggleForeignKey(); } else if (e.getActionCommand().equals(TOGGLE_MATCH_STRING)) { toggleMatchString(); } else { StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(Costanti.class, Costanti.GENERIC_ERROR)); } }
From source file:it.unibas.spicygui.controllo.provider.composition.MyPopupProviderWidgetConstantComposition.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(SET_ROOT)) { } else if (e.getActionCommand().equals(DELETE)) { deleteWidget();//from w ww . j a v a 2 s. c o m } else { } }