List of usage examples for java.awt.event ActionEvent getActionCommand
public String getActionCommand()
From source file:ToolBarDemo2.java
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); String description = null;//from w w w .j a va2 s. co m // Handle each button. if (PREVIOUS.equals(cmd)) { //first button clicked description = "taken you to the previous <something>."; } else if (UP.equals(cmd)) { // second button clicked description = "taken you up one level to <something>."; } else if (NEXT.equals(cmd)) { // third button clicked description = "taken you to the next <something>."; } else if (SOMETHING_ELSE.equals(cmd)) { // fourth button clicked description = "done something else."; } else if (TEXT_ENTERED.equals(cmd)) { // text field JTextField tf = (JTextField) e.getSource(); String text = tf.getText(); tf.setText(""); description = "done something with this text: " + newline + " \"" + text + "\""; } displayResult("If this were a real app, it would have " + description); }
From source file:Main.java
public void actionPerformed(ActionEvent evt) { JComboBox cb = (JComboBox) evt.getSource(); Object newItem = cb.getSelectedItem(); boolean same = newItem.equals(oldItem); oldItem = newItem;//ww w .j a va 2 s . c om if ("comboBoxEdited".equals(evt.getActionCommand())) { // User has typed in a string; only possible with an editable combobox } else if ("comboBoxChanged".equals(evt.getActionCommand())) { // User has selected an item; it may be the same item } }
From source file:PopupDemo.java
public void actionPerformed(ActionEvent e) { System.out.println("actionPerformed, event=" + e + ", mod=" + getMods(e)); System.out.println(" command=" + e.getActionCommand()); System.out.println(" param=" + e.paramString()); System.out.println(" source=" + e.getSource()); }
From source file:net.chaosserver.timelord.swingui.AddTimeDialog.java
/** * @param evt the action event//from www .ja v a2 s. co m */ public void actionPerformed(ActionEvent evt) { if (ACTION_OK.equals(evt.getActionCommand())) { Object selectedItem = comboBox.getSelectedItem(); if (log.isDebugEnabled()) { log.debug("ComboBox selected item is [" + ((selectedItem == null) ? "null" : selectedItem.getClass().getName()) + "] with value [" + ((selectedItem == null) ? "null" : selectedItem) + "]"); } TimelordTask timelordTask = null; if (selectedItem instanceof TimelordTask) { timelordTask = (TimelordTask) selectedItem; } else if (selectedItem instanceof String) { String taskName = (String) selectedItem; int result = JOptionPane.showConfirmDialog(this, "Add new [" + taskName + "] Task?", "Add Task", JOptionPane.YES_NO_OPTION); if (result == 0) { timelordTask = timelordData.addTask(taskName); } } if (timelordTask != null) { TimelordTaskDay timelordTaskDay = timelordTask.getTaskDay(addDate, true); timelordTaskDay.addHours(DateUtil.getSmallestTimeIncremented()); if (timelordTask.isHidden()) { timelordTask.setHidden(true); } this.setVisible(false); } } }
From source file:components.ListDialog.java
public void actionPerformed(ActionEvent e) { if ("Set".equals(e.getActionCommand())) { ListDialog.value = (String) (list.getSelectedValue()); }//from w ww .ja v a 2s .c om ListDialog.dialog.setVisible(false); }
From source file:it.unibas.spicygui.controllo.provider.intermediatezone.MyPopupProviderConnectionFunc.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(DELETE)) { StatusDisplayer.getDefault()/*ww w . j ava 2 s . c o m*/ .setStatusText(NbBundle.getMessage(Costanti.class, Costanti.DELETE_CONNECTION)); deleteConnection(); } else { StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(Costanti.class, Costanti.GENERIC_ERROR)); } }
From source file:events.InternalFrameEventDemo.java
public void actionPerformed(ActionEvent e) { if (SHOW.equals(e.getActionCommand())) { //They clicked the Show button. //Create the internal frame if necessary. if (listenedToWindow == null) { listenedToWindow = new JInternalFrame("Event Generator", true, //resizable true, //closable true, //maximizable true); //iconifiable //We want to reuse the internal frame, so we need to //make it hide (instead of being disposed of, which is //the default) when the user closes it. listenedToWindow.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); //Add an internal frame listener so we can see //what internal frame events it generates. listenedToWindow.addInternalFrameListener(this); //And we mustn't forget to add it to the desktop pane! desktop.add(listenedToWindow); //Set its size and location. We'd use pack() to set the size //if the window contained anything. listenedToWindow.setSize(300, 100); listenedToWindow.setLocation(desktopWidth / 2 - listenedToWindow.getWidth() / 2, desktopHeight - listenedToWindow.getHeight()); }//from w w w.j a v a 2 s. com //Show the internal frame. listenedToWindow.setVisible(true); } else { //They clicked the Clear button. display.setText(""); } }
From source file:com.emental.mindraider.ui.dialogs.FtsJDialog.java
public FtsJDialog() { super(Messages.getString("FtsJDialog.title")); JPanel dialogPanel = new JPanel(); dialogPanel.setBorder(new EmptyBorder(5, 10, 0, 10)); dialogPanel.setLayout(new BorderLayout()); JPanel contentAndButtons = new JPanel(new GridLayout(2, 1)); JPanel contentPanel = new JPanel(new BorderLayout()); // 1a./*from w ww.j ava2s . c o m*/ // TODO add help like in eclipse contentPanel.add(new JLabel(Messages.getString("FtsJDialog.searchString")), BorderLayout.NORTH); // 1b. String[] knownSearches = new String[] { "", "RDF", "mind", "concept", "China" }; ftsCombo = new JComboBox(knownSearches); ftsCombo.setPreferredSize(new Dimension(200, 18)); ftsCombo.setEditable(true); ftsCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if ("comboBoxEdited".equals(e.getActionCommand())) { search(); } } }); contentPanel.add(ftsCombo, BorderLayout.SOUTH); contentAndButtons.add(contentPanel); // 2. JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5)); JButton searchButton = new JButton(Messages.getString("FtsJDialog.searchButton")); searchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { search(); } }); p.add(searchButton); JButton cancelButton = new JButton(Messages.getString("FtsJDialog.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); p.add(cancelButton); contentAndButtons.add(p); dialogPanel.add(contentAndButtons, BorderLayout.CENTER); getContentPane().add(dialogPanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:QandE.LunarPhasesRB.java
public void actionPerformed(ActionEvent event) { phaseIconLabel.setIcon(new ImageIcon("images/image" + event.getActionCommand() + ".jpg")); }
From source file:it.cnr.icar.eric.client.ui.swing.metal.MetalThemeMenu.java
/** * Listener for events from this menu./*w w w. j a v a2 s . c o m*/ */ public void actionPerformed(ActionEvent e) { String numStr = e.getActionCommand(); MetalTheme selectedTheme = themes[Integer.parseInt(numStr)]; MetalLookAndFeel.setCurrentTheme(selectedTheme); try { // I18N: Do not localize next statement. UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception ex) { log.error(themeNames.getString("message.error.failedLoadingMetal"), ex); } }