List of usage examples for java.awt.event ActionEvent getActionCommand
public String getActionCommand()
From source file:de.tor.tribes.ui.views.DSWorkbenchDistanceFrame.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Delete")) { deleteSelectedColumns();/*from w ww. j av a2s.c o m*/ } else if (e.getActionCommand().equals("Paste")) { pasteFromClipboard(); } }
From source file:de.tor.tribes.ui.views.DSWorkbenchWatchtowerFrame.java
/** * Creates new form DSWorkbenchWatchtowerFrame *///from w w w .j av a2 s . co m DSWorkbenchWatchtowerFrame() { initComponents(); centerPanel = new GenericTestPanel(); jWatchtowerPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jXPanel1); buildMenu(); KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false); KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false); ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if ("Delete".equals(e.getActionCommand())) { deleteSelection(); } else if ("BBCopy".equals(e.getActionCommand())) { bbCopySelection(); } } }; capabilityInfoPanel1.addActionListener(listener); jWatchtowerTable.registerKeyboardAction(listener, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jWatchtowerTable.registerKeyboardAction(listener, "BBCopy", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jWatchtowerFrameAlwaysOnTop .setSelected(GlobalOptions.getProperties().getBoolean("watchtower.frame.alwaysOnTop")); setAlwaysOnTop(jWatchtowerFrameAlwaysOnTop.isSelected()); jWatchtowerTable.setModel(new WatchtowerTableModel()); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { //TODO create help page GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.church_view", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> jWatchtowerTable.getSelectionModel().addListSelectionListener(DSWorkbenchWatchtowerFrame.this); pack(); }
From source file:de.tor.tribes.ui.windows.ClockFrame.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("RemoveTimer")) { removeTimer((TimerPanel) e.getSource()); }/*ww w . j a v a 2 s .c o m*/ }
From source file:DateChooserPanel.java
/** * Handles action-events from the date panel. * * @param e information about the event that occurred. *//*w w w . j av a 2s.co m*/ public void actionPerformed(final ActionEvent e) { if (e.getActionCommand().equals("monthSelectionChanged")) { final JComboBox c = (JComboBox) e.getSource(); // In most cases, changing the month will not change the selected // day. But if the selected day is 29, 30 or 31 and the newly // selected month doesn't have that many days, we revert to the // last day of the newly selected month... int dayOfMonth = this.chosenDate.get(Calendar.DAY_OF_MONTH); this.chosenDate.set(Calendar.DAY_OF_MONTH, 1); this.chosenDate.set(Calendar.MONTH, c.getSelectedIndex()); int maxDayOfMonth = this.chosenDate.getActualMaximum(Calendar.DAY_OF_MONTH); this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, maxDayOfMonth)); refreshButtons(); } else if (e.getActionCommand().equals("yearSelectionChanged")) { if (!this.refreshing) { final JComboBox c = (JComboBox) e.getSource(); final Integer y = (Integer) c.getSelectedItem(); // in most cases, changing the year will not change the // selected day. But if the selected day is Feb 29, and the // newly selected year is not a leap year, we revert to // Feb 28... int dayOfMonth = this.chosenDate.get(Calendar.DAY_OF_MONTH); this.chosenDate.set(Calendar.DAY_OF_MONTH, 1); this.chosenDate.set(Calendar.YEAR, y.intValue()); int maxDayOfMonth = this.chosenDate.getActualMaximum(Calendar.DAY_OF_MONTH); this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, maxDayOfMonth)); refreshYearSelector(); refreshButtons(); } } else if (e.getActionCommand().equals("todayButtonClicked")) { setDate(new Date()); } else if (e.getActionCommand().equals("dateButtonClicked")) { final JButton b = (JButton) e.getSource(); final int i = Integer.parseInt(b.getName()); final Calendar cal = getFirstVisibleDate(); cal.add(Calendar.DATE, i); setDate(cal.getTime()); } }
From source file:com.emr.schemas.SavedProcessesDataMover.java
/** * Constructor/*from ww w. j a v a 2s . co m*/ */ public SavedProcessesDataMover() { initComponents(); this.setClosable(true); final Action processDelete = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { JTable table = (JTable) e.getSource(); int modelRow = Integer.valueOf(e.getActionCommand()); String foreignKeysTable = (String) tblProcesses.getModel().getValueAt(modelRow, 0); if (foreignKeysTable == null || "".equals(foreignKeysTable)) { JOptionPane.showMessageDialog(null, "Table is Empty", "Empty Table", JOptionPane.ERROR_MESSAGE); } else { } } }; final SQLiteGetProcesses sp = new SQLiteGetProcesses(); sp.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { switch (event.getPropertyName()) { case "progress": System.out.println("Fetching data from db"); break; case "state": switch ((SwingWorker.StateValue) event.getNewValue()) { case DONE: try { model = sp.get(); tblProcesses.setModel(model); tblProcesses.getColumnModel().getColumn(0).setMaxWidth(300); //hide irrelevant columns tblProcesses.getColumnModel().getColumn(2).setMinWidth(0); tblProcesses.getColumnModel().getColumn(2).setMaxWidth(0); tblProcesses.getColumnModel().getColumn(3).setMinWidth(0); tblProcesses.getColumnModel().getColumn(3).setMaxWidth(0); tblProcesses.getColumnModel().getColumn(4).setMinWidth(0); tblProcesses.getColumnModel().getColumn(4).setMaxWidth(0); tblProcesses.getColumnModel().getColumn(5).setMinWidth(0); tblProcesses.getColumnModel().getColumn(5).setMaxWidth(0); tblProcesses.getColumnModel().getColumn(6).setMinWidth(0); tblProcesses.getColumnModel().getColumn(6).setMaxWidth(0); ButtonColumn buttonColumn = new ButtonColumn(tblProcesses, processDelete, 7, "Delete"); } catch (final CancellationException ex) { Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionException ex) { Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex); } break; } break; } } }); sp.execute(); tblProcesses.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { JTable target = (JTable) e.getSource(); int rowIndex = target.getSelectedRow(); String selectQry = (String) target.getModel().getValueAt(rowIndex, 2); String destinationTable = (String) target.getModel().getValueAt(rowIndex, 3); String truncateFirst = (String) target.getModel().getValueAt(rowIndex, 4); String destinationColumns = (String) target.getModel().getValueAt(rowIndex, 5); String columnsToBeMapped = (String) target.getModel().getValueAt(rowIndex, 6); lblUpdateText.setText("<html><b color='red'>Moving Data</b></html>"); dbProgressBar.setIndeterminate(true); new DBUpdater(selectQry, destinationTable, truncateFirst, destinationColumns, columnsToBeMapped) .execute(); } } @Override public void mousePressed(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseReleased(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseEntered(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseExited(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); }
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultPlotEditor.java
/** * Handles user actions generated within the panel. * /*from w ww .ja va 2 s.c o m*/ * @param event * the event */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals("BackgroundPaint")) { attemptBackgroundPaintSelection(); } else if (command.equals("OutlinePaint")) { attemptOutlinePaintSelection(); // Disabled because makes no sense for us // } else if (command.equals("Orientation")) { // attemptOrientationSelection(); } else if (command.equals("DrawLines")) { attemptDrawLinesSelection(); } else if (command.equals("DrawShapes")) { attemptDrawShapesSelection(); } }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
public void actionPerformed(ActionEvent arg0) { String name = arg0.getActionCommand(); if (arg0.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) arg0.getSource(); if (j.isSelected()) { createPlotInWindow(name);//w w w . j a v a 2s .c om } else { deletePlotInWindow(name); } } else { if (name.contains("Average Metrics")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(0)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(0)); } } else if (name.contains("General Metrics")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(1)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(1)); } } else if (name.contains("Metrics for Receiving")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(2)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(2)); } } else if (name.contains("Metrics for Sending")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(3)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(3)); } } else { for (int i = 0; i < mb.getMenu(1).getMenuComponentCount(); i++) { if (mb.getMenu(1).getMenuComponent(i) instanceof JMenu) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(i)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(i)); } } } } } validate(); repaint(); Runtime.getRuntime().gc(); }
From source file:de.tor.tribes.ui.views.DSWorkbenchRankFrame.java
@Override public void actionPerformed(ActionEvent e) { RankTableTab activeTab = getActiveTab(); if (e.getActionCommand() != null && activeTab != null) { if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3);/* w ww . ja v a 2 s . c o m*/ g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxSearchPane.setBackgroundPainter(new MattePainter(paint)); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < activeTab.getRankTable().getColumnCount(); i++) { TableColumnExt col = activeTab.getRankTable().getColumnExt(i); if (col.isVisible()) { if (col.getTitle().equals("Name") || col.getTitle().equals("Tag") || col.getTitle().equals("Stamm")) { model.addElement(col.getTitle()); } } } jXColumnList.setModel(model); jXColumnList.setSelectedIndex(0); jxSearchPane.setVisible(true); } } }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java
JButton createChooseBetweenImdbAndLocalDatabaseButton() { /*This button choses between IMDB and local movie database*/ final JButton chooseBetweenImdbAndLocalDatabase = new JButton( Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase/*from w w w .j av a 2s . c o m*/ .setToolTipText(Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.tooltip")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.setActionCommand("GetIMDBInfo - chooseBetweenImdbAndLocalDatabase"); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { log.debug("ActionPerformed: " + event.getActionCommand()); //$NON-NLS-1$ if (addInfoToExistingMovie) { getPanelMoviesList().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(5, 5, 5, 5))); chooseBetweenImdbAndLocalDatabase .setText(Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.setToolTipText( Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.tooltip")); //$NON-NLS-1$ addInfoToExistingMovie = false; executeSearchMultipleMovies(); } else { executeEditExistingMovie(""); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase .setText(Localizer.get("DialogIMDbMultiAdd.button.search-on-IMDb.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase .setToolTipText(Localizer.get("DialogIMDbMultiAdd.button.search-on-IMDb.tooltip")); //$NON-NLS-1$ addInfoToExistingMovie = true; getPanelMoviesList().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-your-movie-list.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(5, 5, 5, 5))); } } }); return chooseBetweenImdbAndLocalDatabase; }
From source file:de.juwimm.cms.Main.java
public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try {/*w w w. ja v a2s . c o m*/ if (action.equals(Constants.ACTION_EXIT)) { if (ActionHub.fireExitPerformed(new ExitEvent())) { comm.getDbHelper().shutdown(); System.exit(0); } } else if (action.equals(Constants.ACTION_LOGIN)) { this.setLayout(new BorderLayout()); Constants.CMS_CLIENT_VIEW = -1; setCenterPanel(PanInitView.getInstance()); if (panStatusbar == null) { panStatusbar = new PanStatusbar(); UIConstants.setStatusLine(panStatusbar); ActionHub.addActionListener(panStatusbar); } if (panRibbon == null) { panRibbon = new PanRibbon(comm); ActionHub.addActionListener(panRibbon); } this.getContentPane().add(panRibbon, BorderLayout.NORTH); ActionHub.fireActionPerformed( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Constants.ACTION_VIEW_EDITOR)); // this.getJMenuBar().setVisible(true); // this.getContentPane().add(panToolbar, BorderLayout.NORTH); this.getContentPane().add(panStatusbar, BorderLayout.SOUTH); this.getRootPane().setDoubleBuffered(true); this.getRootPane().validate(); this.getRootPane().repaint(); } else if (action.equals(Constants.ACTION_LOGOFF)) { if (ActionHub.fireExitPerformed(new ExitEvent())) { comm.setLoggedIn(false); Application.initializeContext(); panLogin = new PanLogin(); panRoot = null; panAdmin = null; panRibbon = null; this.getContentPane().removeAll(); //this.getJMenuBar().setVisible(false); comm.getDbHelper().autoEmptyCache(); PanContentView.getInstance().unloadAll(); setCenterPanel(panLogin); Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_LOGIN; this.validate(); this.getContentPane().validate(); this.getContentPane().repaint(); this.repaint(); panLogin.init(); } } else if (action.equals(Constants.ACTION_VIEW_EDITOR)) { showToolPanel(false, e); panTool = PanTool.getInstance(); Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT; } else if (action.equals(Constants.ACTION_VIEW_EDITOR_WITH_SELECTION)) { showToolPanel(true, e); panTool = PanTool.getInstance(); Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT; } else if (action.equals(Constants.ACTION_VIEW_ADMIN) || action.equals(Constants.ACTION_VIEW_ROOT)) { Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_ADMIN; showAdminPanel(); panStatusbar.setCountVisible(false); } else if (action.equals(Constants.ACTION_CHANGE_PASSWORD)) { showChangePasswordDialog(); } else if (action.equals(Constants.ACTION_SHOW_TASK)) { showTaskPanel(); panStatusbar.setCountVisible(false); Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_TASK; } else if (action.equals(Constants.ACTION_SHOW_CONTENT)) { Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT; } } catch (Exception exe) { log.error("Error in actionPerformed", exe); } finally { this.setCursor(Cursor.getDefaultCursor()); } }