List of usage examples for java.awt.event ActionEvent getActionCommand
public String getActionCommand()
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
/** * * * @param event/*from w ww .java2 s .c om*/ */ public void actionPerformed(ActionEvent event) { // Get the name of the action command String command = event.getActionCommand(); if ((stopAction != null) && command.equals(stopAction.getActionCommand())) { stopRecording(); } if ((recordAction != null) && command.equals(recordAction.getActionCommand())) { // We need to go back to windowed mode if in full screen mode setFullScreenMode(false); // Select the file to record to JFileChooser fileDialog = new JFileChooser(System.getProperty("user.home")); int ret = fileDialog.showSaveDialog(this); if (ret == fileDialog.APPROVE_OPTION) { recordingFile = fileDialog.getSelectedFile(); if (recordingFile.exists() && (JOptionPane.showConfirmDialog(this, "File exists. Are you sure?", "File exists", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION)) { return; } try { recordingOutputStream = new FileOutputStream(recordingFile); statusBar.setStatusText("Recording to " + recordingFile.getName()); setAvailableActions(); } catch (IOException ioe) { showExceptionMessage("Error", "Could not open file for recording\n\n" + ioe.getMessage()); } } } if ((playAction != null) && command.equals(playAction.getActionCommand())) { // We need to go back to windowed mode if in full screen mode setFullScreenMode(false); // Select the file to record to JFileChooser fileDialog = new JFileChooser(System.getProperty("user.home")); int ret = fileDialog.showOpenDialog(this); if (ret == fileDialog.APPROVE_OPTION) { File playingFile = fileDialog.getSelectedFile(); InputStream in = null; try { statusBar.setStatusText("Playing from " + playingFile.getName()); in = new FileInputStream(playingFile); byte[] b = null; int a = 0; while (true) { a = in.available(); if (a == -1) { break; } if (a == 0) { a = 1; } b = new byte[a]; a = in.read(b); if (a == -1) { break; } //emulation.write(b); emulation.getOutputStream().write(b); } statusBar.setStatusText("Finished playing " + playingFile.getName()); setAvailableActions(); } catch (IOException ioe) { statusBar.setStatusText("Error playing " + playingFile.getName()); showExceptionMessage("Error", "Could not open file for playback\n\n" + ioe.getMessage()); } finally { if (in != null) { try { in.close(); } catch (IOException ioe) { log.error(ioe); } } } } } if ((closeAction != null) && command.equals(closeAction.getActionCommand())) { closeSession(); } }
From source file:de.tor.tribes.ui.views.DSWorkbenchReTimerFrame.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Copy")) { copySelectionToInternalClipboard(); } else if (e.getActionCommand().equals("BBCopy")) { copyAttacksToClipboardAsBBCode(); } else if (e.getActionCommand().equals("Cut")) { cutSelectionToInternalClipboard(); } else if (e.getActionCommand().equals("Delete")) { removeSelection();/*from w w w. ja va 2 s. co m*/ } }
From source file:com.att.aro.ui.view.diagnostictab.GraphPanel.java
@Override public void actionPerformed(ActionEvent e) { if (ZOOM_IN_ACTION.equals(e.getActionCommand())) { zoomIn();// w w w . ja v a 2 s .c o m } else if (ZOOM_OUT_ACTION.equals(e.getActionCommand())) { zoomOut(); } else if (REFRESH_AS_ACTION.equals(e.getActionCommand())) { // Greg // Story filterFlowTable(); } else if (SAVE_AS_ACTION.equals(e.getActionCommand())) { graphHelper.SaveImageAs(getViewport(), getTraceData().getAnalyzerResult().getTraceresult().getTraceDirectory()); } }
From source file:SoundManagerTest.java
/** * Performs actions when a button is pressed. *///from www. j av a 2s . c o m public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); AbstractButton button = (AbstractButton) e.getSource(); if (command == EXIT) { midiPlayer.close(); soundManager.close(); stop(); } else if (command == PAUSE) { // pause the sound soundManager.setPaused(button.isSelected()); midiPlayer.setPaused(button.isSelected()); } else if (command == PLAY_MUSIC) { // toggle music on or off if (button.isSelected()) { midiPlayer.play(music, true); } else { midiPlayer.stop(); } } else if (command == MUSIC_DRUMS) { // toggle drums on or off Sequencer sequencer = midiPlayer.getSequencer(); if (sequencer != null) { boolean mute = sequencer.getTrackMute(DRUM_TRACK); sequencer.setTrackMute(DRUM_TRACK, !mute); } } else if (command == PLAY_SOUND) { // play a normal sound soundManager.play(boop); } else if (command == PLAY_ECHO_SOUND) { // play a sound with an echo EchoFilter filter = new EchoFilter(11025, .6f); soundManager.play(boop, filter, false); } else if (command == PLAY_LOOPING_SOUND) { // play or stop the looping sound if (button.isSelected()) { lastloopingSound = soundManager.play(bzz, null, true); } else if (lastloopingSound != null) { try { lastloopingSound.close(); } catch (IOException ex) { } lastloopingSound = null; } } else if (command == PLAY_MANY_SOUNDS) { // play several sounds at once, to test the system for (int i = 0; i < MANY_SOUNDS_COUNT; i++) { soundManager.play(boop); } } }
From source file:at.becast.youploader.gui.FrmMain.java
public void loadAccounts() { int i = 0;// w w w.j a v a 2 s . c o m HashMap<AccountType, Integer> accounts = accMng.load(); for (Entry<AccountType, Integer> entry : accounts.entrySet()) { getCmbAccount().addItem(entry.getKey()); AccListModel.addElement(entry.getKey()); JMenuItem rdoBtn = new JMenuItem(entry.getKey().toString()); if (entry.getValue() == 1) { rdoBtn.setSelected(true); getCmbAccount().setSelectedItem(entry.getKey()); } rdoBtn.setActionCommand(entry.getKey().toString()); rdoBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editAccount(e.getActionCommand()); } }); _accounts.put(i, rdoBtn); mnuAcc.add(rdoBtn); i++; } if (!accounts.isEmpty()) { btnAddToQueue.setEnabled(true); } }
From source file:net.lmxm.ute.gui.MainFrame.java
@Override public void actionPerformed(final ActionEvent actionEvent) { try {/*w ww .j a v a2 s . c om*/ final ActionCommand actionCommand = ActionCommand.valueOf(actionEvent.getActionCommand()); if (actionCommand.equals(ABOUT)) { actionAbout(); } else if (actionCommand == ADD_FILE_SYSTEM_DELETE_TASK) { actionAddFileSystemDeleteTask(); } else if (actionCommand == ADD_FILE_SYSTEM_LOCATION) { actionAddFileSystemLocation(); } else if (actionCommand == ADD_FIND_REPLACE_TASK) { actionAddFindReplaceTask(); } else if (actionCommand == ADD_GROOVY_TASK) { actionAddGroovyTask(); } else if (actionCommand == ADD_HTTP_DOWNLOAD_TASK) { actionAddHttpDownloadTask(); } else if (actionCommand == ADD_HTTP_LOCATION) { actionAddHttpLocation(); } else if (actionCommand == ADD_MAVEN_REPOSITORY_DOWNLOAD_TASK) { actionAddMavenRepositoryDownloadTask(); } else if (actionCommand == ADD_MAVEN_REPOSITORY_LOCATION) { actionAddMavenRepositoryLocation(); } else if (actionCommand == ADD_JOB) { actionAddJob(); } else if (actionCommand == ADD_PREFERENCE) { actionAddPreference(); } else if (actionCommand == ADD_PROPERTY) { actionAddProperty(); } else if (actionCommand == ADD_SUBVERSION_EXPORT_TASK) { actionAddSubversionExportTask(); } else if (actionCommand == ADD_SUBVERSION_REPOSITORY_LOCATION) { actionAddSubversionRepositoryLocation(); } else if (actionCommand == ADD_SUBVERSION_UPDATE_TASK) { actionAddSubversionUpdateTask(); } else if (actionCommand == ADD_TASK) { actionAddTask(); } else if (actionCommand == CLONE_FILE_SYSTEM_LOCATION) { actionCloneFileSystemLocation(); } else if (actionCommand == CLONE_HTTP_LOCATION) { actionCloneHttpLocation(); } else if (actionCommand == CLONE_JOB) { actionCloneJob(); } else if (actionCommand == CLONE_MAVEN_REPOSITORY_LOCATION) { actionCloneMavenRepositoryLocation(); } else if (actionCommand == CLONE_PREFERENCE) { actionClonePreference(); } else if (actionCommand == CLONE_PROPERTY) { actionCloneProperty(); } else if (actionCommand == CLONE_SUBVERSION_REPOSITORY_LOCATION) { actionCloneSubversionRepositoryLocation(); } else if (actionCommand == CLONE_TASK) { actionCloneTask(); } else if (actionCommand == COLLAPSE) { actionCollapse(); } else if (actionCommand == DELETE_FILE_SYSTEM_LOCATION) { actionDeleteFileSystemLocation(); } else if (actionCommand == DELETE_HTTP_LOCATION) { actionDeleteHttpLocation(); } else if (actionCommand == DELETE_JOB) { actionDeleteJob(); } else if (actionCommand == DELETE_MAVEN_REPOSITORY_LOCATION) { actionDeleteMavenRepositoryLocation(); } else if (actionCommand == DELETE_PREFERENCE) { actionDeletePreference(); } else if (actionCommand == DELETE_PROPERTY) { actionDeleteProperty(); } else if (actionCommand == DELETE_SUBVERSION_REPOSITORY_LOCATION) { actionDeleteSubversionRepositoryLocation(); } else if (actionCommand == DELETE_TASK) { actionDeleteTask(); } else if (actionCommand == EDIT_PREFERENCES) { actionEditPreferences(); } else if (actionCommand == EXIT) { actionExit(); } else if (actionCommand == EXPAND) { actionExpand(); } else if (actionCommand == EXECUTE) { actionExecute(); } else if (actionCommand == NEW_FILE) { actionNewFile(); } else if (actionCommand == OPEN_FILE) { actionOpenFile(); } else if (actionCommand == RELOAD_FILE) { actionReloadFile(); } else if (actionCommand == SAVE_FILE) { actionSaveFile(); } else if (actionCommand == SAVE_FILE_AS) { actionSaveFileAs(); } } catch (final Exception exception) { displayError(exception); } }
From source file:es.emergya.ui.gis.CustomMapView.java
public CustomMapView() { super();//from w w w . j av a 2s .co m menu = new MainMenu(); contentPane.add(panel, BorderLayout.CENTER); // iniciar los controles mostrar/ocultar capas layerControls = new LinkedList<JToggleButton>(); JToggleButton botonMostrarOcultarBotones = new JToggleButton(getI18n().getString("map.layers.hideButtons"), LogicConstants.getIcon("capas_button_mostrar"), false); botonMostrarOcultarBotones.setSelected(true); botonMostrarOcultarBotones.setActionCommand("#hide"); // b.setVerticalTextPosition(SwingConstants.BOTTOM); // b.setHorizontalTextPosition(SwingConstants.CENTER); botonMostrarOcultarBotones.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JToggleButton b = (JToggleButton) e.getSource(); if (e.getActionCommand().equals("#hide")) { layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); layerControlPanel.add(b); b.setActionCommand("#show"); b.setText(getI18n().getString("map.layers.showButtons")); } else { layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); for (JToggleButton bt : layerControls) { layerControlPanel.add(bt); layerControlPanel.add(Box.createHorizontalGlue()); } b.setActionCommand("#hide"); b.setText(getI18n().getString("map.layers.hideButtons")); } layerControlPanel.updateUI(); } }); layerControls.add(botonMostrarOcultarBotones); final JToggleButton botonTodoasLasCapas = new JToggleButton(getI18n().getString("map.layers.allLayers"), LogicConstants.getIcon("capas_button_mostrar"), false); layerDialog = new LayerSelectionDialog(this); layerDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { botonTodoasLasCapas.setSelected(false); } }); botonTodoasLasCapas.setSelected(false); botonTodoasLasCapas.setActionCommand("#all"); // all.setVerticalTextPosition(SwingConstants.BOTTOM); // all.setHorizontalTextPosition(SwingConstants.CENTER); botonTodoasLasCapas.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { layerDialog.setLocationRelativeTo((Component) e.getSource()); layerDialog.setVisible(!layerDialog.isShowing()); } }); layerControls.add(botonTodoasLasCapas); layerControlPanel = new JPanel(); layerControlPanel.setLayout(new BoxLayout(layerControlPanel, BoxLayout.X_AXIS)); Main.main.menu = this.menu; toolbar = new ToolbarPreferences(); toolbar.refreshToolbarControl(); // toolbar.control.updateUI(); // contentPane.add(toolbar.control, BorderLayout.NORTH); contentPane.updateUI(); panel.updateUI(); }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
@Override public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals(RESET_COLOR_SCALE_COMMAND)) { PaintScaleLegend legend = getPaintScaleLegend(); if (legend != null && legend.getScale() instanceof ColorPaintScale) { ((ColorPaintScale) legend.getScale()).resetBoundPercentage(); updatePlot();/*from www. ja v a 2 s . c om*/ } } else { super.actionPerformed(event); } }
From source file:com.sshtools.powervnc.PowerVNCPanel.java
public void actionPerformed(ActionEvent evt) { if (evt.getSource() == receiveTimer) { statusBar.setReceiving(false);//from w w w. j a v a 2 s . c o m } else if (evt.getSource() == sendTimer) { statusBar.setSending(false); } if (sessionActions.containsKey(evt.getActionCommand())) { SessionProviderAction action = (SessionProviderAction) sessionActions.get(evt.getActionCommand()); SessionProviderFrame frame; // Do we have an existing frame? for (Iterator it = sessionFrames.iterator(); it.hasNext();) { frame = (SessionProviderFrame) it.next(); if (action.getProvider().getProviderClass().isInstance(frame)) { frame.show(); return; } } try { frame = new SessionProviderFrame(getCurrentConnectionProfile(), ssh, action.getProvider()); if (frame.initFrame(getApplication())) { frame.show(); sessionFrames.add(frame); } } catch (Throwable ex) { } } }
From source file:javazoom.jlgui.player.amp.PlayerUI.java
public void actionPerformed(ActionEvent e) { final ActionEvent evt = e; if (e.getActionCommand().equals(PlayerActionEvent.ACPAUSE)) { processActionEvent(e);// w w w . j ava 2s . co m } else if ((e.getActionCommand().equals(PlayerActionEvent.ACPLAY)) && (playerState == PAUSE)) { processActionEvent(e); } else { new Thread("PlayerUIActionEvent") { public void run() { processActionEvent(evt); } }.start(); } }