List of usage examples for java.awt.event ActionEvent paramString
@SuppressWarnings("deprecation") public String paramString()
From source file:Main.java
public static void main(final String args[]) { final String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Selecting JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox comboBox = new JComboBox(labels); frame.add(comboBox, BorderLayout.SOUTH); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Command: " + actionEvent.getActionCommand()); ItemSelectable is = (ItemSelectable) actionEvent.getSource(); System.out.println(", Selected: " + selectedString(is)); System.out.println("paramString:" + actionEvent.paramString()); }// w w w. jav a2s . c o m }; comboBox.addActionListener(actionListener); frame.setSize(400, 200); frame.setVisible(true); }
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:Main.java
public Main() { this.setLayout(new GridLayout(0, 1)); this.add(new JLabel("Dialog event test.", JLabel.CENTER)); this.add(new JButton(new AbstractAction("Close") { @Override//from w w w . j a v a2s. co m public void actionPerformed(ActionEvent e) { Main.this.setVisible(false); Main.this.dispatchEvent(new WindowEvent(Main.this, WindowEvent.WINDOW_CLOSING)); } })); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println(e.paramString()); } }); }
From source file:ca.uviccscu.lp.server.main.MainFrame.java
@Deprecated public static void setupTablePopupOld() { JMenuItem menuItem = new JMenuItem("Start"); menuItem.addActionListener(new ActionListener() { @Override/*from w w w . jav a2 s . c o m*/ public void actionPerformed(final ActionEvent e) { /* lockInterface(); l.trace(e.paramString()); int row = jTable1.rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY)); String game = (String) jTable1.getModel().getValueAt(row, 0); l.trace("Popup action! row: " + row + " and name " + game); int status = GamelistStorage.getGame(game).gameStatus; if (status == 0) { File g = new File(GamelistStorage.getGame(game).gameAbsoluteFolderPath); File tp = new File(Utils.concatenatePaths(new String[]{Shared.workingDirectory, Shared.torrentStoreSubDirectory})); try { TOTorrent t = TrackerManager.createNewTorrent(g, tp, new ProgressListener(game)); TrackerManager.getCore().addTorrentToTracker(t, tp.getAbsolutePath(), g.getAbsolutePath()); } catch (Exception ex) { l.error("Torrent create failed: " + game, ex); } } else if (status == 1||status == 2) { l.error("Game torrent already created"); } else { l.error("Game has been run already"); } unlockInterface(); * */ SwingWorker worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { MainFrame.lockInterface(); l.trace(e.paramString()); int row = jTable1 .rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY)); String game = (String) jTable1.getModel().getValueAt(row, 0); l.trace("Popup start action! row: " + row + " and name " + game); int status = GamelistStorage.getGame(game).gameStatus; if (status == 0) { File g = new File(GamelistStorage.getGame(game).gameAbsoluteFolderPath); File tp = new File(Shared.workingDirectory + Shared.torrentStoreSubDirectory + "\\" + GamelistStorage.getGame(game).gameName + ".torrent"); try { MainFrame.setReportingActive(); TOTorrent t = TrackerManager.createNewTorrent(g, tp, new HashingProgressListener(game)); TrackerManager.getCore().addTorrentToTracker(t, tp.getAbsolutePath(), g.getAbsolutePath()); GamelistStorage.getGame(game).gameStatus = 1; MainFrame.setReportingIdle(); } catch (Exception ex) { l.error("Torrent create failed: " + game, ex); } } else if (status == 1 || status == 2) { l.error("Game torrent already created"); } else if (status == 4) { TrackerManager.getCore() .resumeTorrentSeeding(GamelistStorage.getGame(game).gameTorrent); TrackerManager.getCore() .resumeTorrentTracking(GamelistStorage.getGame(game).gameTorrent); } else { l.error("Game has been started already"); } return null; } @Override public void done() { MainFrame.updateProgressBar(-1, 0, 100000, "Idle", true, true); MainFrame.updateProgressBar(-1, 0, 100000, "Idle", false, true); MainFrame.updateTask("Idle...", true); MainFrame.unlockInterface(); } }; worker.execute(); } }); popupMenu.add(menuItem); JMenuItem menuItem2 = new JMenuItem("Stop"); menuItem2.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { SwingWorker worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { MainFrame.lockInterface(); l.trace(e.paramString()); int row = jTable1 .rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY)); String game = (String) jTable1.getModel().getValueAt(row, 0); l.trace("Popup stop action! row: " + row + " and name " + game); Game g = GamelistStorage.getGame(game); int status = g.gameStatus; if (status == 3) { try { TrackerManager.getCore() .pauseTorrentSeeding(GamelistStorage.getGame(game).gameTorrent); TrackerManager.getCore() .pauseTorrentTracking(GamelistStorage.getGame(game).gameTorrent); g.gameStatus = 4; } catch (Exception ex) { l.error("Torrent create failed: " + game, ex); } } else if (status == 1 || status == 2) { l.error("Game torrent already created"); } else { l.error("Game has been started already"); } return null; } @Override public void done() { MainFrame.updateProgressBar(-1, 0, 100000, "Idle", true, true); MainFrame.updateProgressBar(-1, 0, 100000, "Idle", false, true); MainFrame.updateTask("Idle...", true); MainFrame.unlockInterface(); } }; worker.execute(); } }); //menuItem.addActionListener(new ActionAdapter(this)); popupMenu.add(menuItem2); MouseListener popupListener = new PopupListener(); jTable1.addMouseListener(popupListener); }