List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:MyActionListener.java
public void actionPerformed(ActionEvent e) { System.out.println("Command: " + e.getActionCommand()); int modifiers = e.getModifiers(); System.out.println("\tALT : " + checkMod(modifiers, ActionEvent.ALT_MASK)); System.out.println("\tCTRL : " + checkMod(modifiers, ActionEvent.CTRL_MASK)); System.out.println("\tMETA : " + checkMod(modifiers, ActionEvent.META_MASK)); System.out.println("\tSHIFT: " + checkMod(modifiers, ActionEvent.SHIFT_MASK)); Object source = e.getSource(); if (source instanceof JButton) { JButton jb = (JButton) source; System.out.println("JButton: " + jb.getText()); }//from w w w.j a v a 2 s . com }
From source file:InterleavedNIOBuffer.java
public void actionPerformed(ActionEvent e) { Object target = e.getSource(); if (target == geomType) { shape.setGeometry(geoArrays[geomType.getSelectedIndex()]); } else if (target == transparency) { if (transparency.isSelected()) { transp.setTransparencyMode(TransparencyAttributes.BLENDED); } else {//w ww.j av a 2 s . co m transp.setTransparencyMode(TransparencyAttributes.NONE); } } else if (target == textureBox) { if (textureBox.isSelected()) { app.setTextureUnitState(textureUnitState); } else { app.setTextureUnitState(null); } } }
From source file:net.schweerelos.parrot.CombinedParrotApp.java
@SuppressWarnings("serial") private JToggleButton setupNavigatorButton(final String name, final String accelerator, final NavigatorComponent navigator) { final Component component = navigator.asJComponent(); AbstractAction showNavigatorAction = new AbstractAction(name) { @Override// w w w.j ava 2s .c o m public void actionPerformed(ActionEvent e) { if (!(e.getSource() instanceof JToggleButton)) { return; } final Window window; if (component instanceof Window) { window = (Window) component; } else { window = SwingUtilities.getWindowAncestor(component); } JToggleButton button = (JToggleButton) e.getSource(); boolean show = button.isSelected(); if (show) { if (window != CombinedParrotApp.this && preferredFrameLocations.containsKey(window)) { window.setLocation(preferredFrameLocations.get(window)); } } if (navigator.tellSelectionWhenShown()) { Collection<NodeWrapper> selectedNodes = activeMainView.getSelectedNodes(); navigator.setSelectedNodes(selectedNodes); } component.setVisible(show); if (show) { window.setVisible(true); } else if (window != CombinedParrotApp.this) { window.setVisible(false); } } }; showNavigatorAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control " + accelerator)); final JToggleButton button = new JToggleButton(showNavigatorAction); button.setToolTipText("Show " + name.toLowerCase()); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button.setToolTipText((button.isSelected() ? "Hide " : "Show ") + name.toLowerCase()); } }); final Window window; if (component instanceof Window) { window = (Window) component; } else { window = SwingUtilities.getWindowAncestor(component); } if (window != null) { window.addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { button.setSelected(false); if (window != CombinedParrotApp.this) { preferredFrameLocations.put(window, window.getLocation()); } } @Override public void componentShown(ComponentEvent e) { button.setSelected(true); } }); } return button; }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); try {/*from w w w . java 2s. co m*/ if (source == btnEnlarged) { displayEnlarged(); } else if (source == btnSaveChart) { SaveChartDialog dialog = new SaveChartDialog(ownerDialog, chart); dialog.setVisible(true); } else if (source == btnSaveData) { saveChartData(); } else if (source == btnFilter) { performFilter(); } else if (source == btnChartSettings) { if (changeVisSettings()) { repaint(); } } else if (btnsDec != null) { for (int i = 0; i < btnsDec.length; ++i) { if (source == btnsDec[i]) { Decorator dec = decorators[i]; if (dec.isActive()) { dec.undecorate(chart); } else { dec.decorate(ownerDialog, chart, visualizer, true); } btnsDec[i].setText(dec.getButtonLabel()); btnsDec[i].setToolTipText(dec.getButtonToolTip()); break; } } } } catch (InnerException ex) { // NetworkAnalyzer internal error logger.error(Messages.SM_LOGERROR, ex); } }
From source file:PrintCanvas3D.java
public void actionPerformed(ActionEvent event) { Object target = event.getSource(); if ((target == snapshotItem) || (target == printItem)) { Point loc = canvas3D.getLocationOnScreen(); offScreenCanvas3D.setOffScreenLocation(loc); Dimension dim = canvas3D.getSize(); dim.width *= OFF_SCREEN_SCALE;/*from w ww. jav a 2s. c om*/ dim.height *= OFF_SCREEN_SCALE; BufferedImage bImage = offScreenCanvas3D.doRender(dim.width, dim.height); if (target == snapshotItem) { new ImageDisplayer(bImage); } else { // (target == printItem) new ImagePrinter(bImage).print(); } } else if (target == quitItem) { u.removeAllLocales(); System.exit(0); } }
From source file:bridge.toolkit.ControllerJFrame.java
private void SelectionDropDownActionPerformed(java.awt.event.ActionEvent evt) { javax.swing.JComboBox cb = (javax.swing.JComboBox) (evt.getSource()); int val = cb.getSelectedIndex(); switch (val) { case 0:/*from w w w . j a va 2 s . c om*/ outputType = "-scormflash"; break; case 1: outputType = "-scormhtml"; break; case 2: outputType = "-mobile"; break; case 3: outputType = "-mobilecourse"; break; case 4: outputType = "-pdfinstructor"; break; case 5: outputType = "-pdfstudent"; break; } }
From source file:edu.ku.brc.specify.datamodel.busrules.LoanBusRules.java
@Override public void initialize(Viewable viewableArg) { super.initialize(viewableArg); formViewObj.setSkippingAttach(true); if (isEditMode()) { Component closedComp = formViewObj.getControlByName("isClosed"); if (closedComp instanceof JCheckBox) { ((JCheckBox) closedComp).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (((JCheckBox) e.getSource()).isSelected()) { Component dateComp = formViewObj.getControlByName("dateClosed"); if (dateComp != null && dateComp instanceof ValFormattedTextFieldSingle) { ValFormattedTextFieldSingle loanDateComp = (ValFormattedTextFieldSingle) dateComp; //System.out.println("["+loanDateComp.getText()+"]"); if (StringUtils.isEmpty(loanDateComp.getText())) { DateWrapper scrDateFormat = AppPrefsCache.getDateWrapper("ui", "formatting", "scrdateformat"); loanDateComp.setText(scrDateFormat.format(Calendar.getInstance())); }// ww w . jav a 2 s.com } } } }); } } /*if (formViewObj.getRsController() != null) { JButton newBtn = formViewObj.getRsController().getNewRecBtn(); if (newBtn != null) { // Remove all ActionListeners, there should only be one for (ActionListener al : newBtn.getActionListeners()) { newBtn.removeActionListener(al); } newBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CommandAction cmdAction = new CommandAction(CMDTYPE, NEW_LOAN, null); cmdAction.setData(cmdAction); // simulating a click CommandDispatcher.dispatch(cmdAction); } }); } }*/ }
From source file:es.emergya.ui.plugins.LayerSelectionDialog.java
@Override public void actionPerformed(ActionEvent e) { String name = e.getActionCommand(); for (LayerElement le : layers) { if (le.name.equals(name)) { if (((JCheckBox) e.getSource()).isSelected()) { enableLayer(le);//from w w w . j a va2 s. co m } else { if (le.layer == null) { for (Layer l : mv.getAllLayers()) { if (l.name.equals(le.name)) { le.layer = l; break; } } } if (le.layer != null) { le.layer.visible = false; } le.active = false; } save(name, le.active); mv.repaint(); } } }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.ADAP3DecompositionV2SetupDialog.java
@Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); final Object source = e.getSource(); if (source.equals(chkPreview)) { if (chkPreview.isSelected()) { // Set the height of the chkPreview to 200 cells, so it will span // the whole vertical length of the dialog (buttons are at row // no 100). Also, we set the weight to 10, so the chkPreview // component will consume most of the extra available space. mainPanel.add(pnlPlots, 3, 0, 1, 200, 10, 10, GridBagConstraints.BOTH); pnlUIElements.add(pnlComboBoxes, BorderLayout.CENTER); // cboPeakLists.setSelectedIndex(0); } else {/*w ww .j a v a 2 s. co m*/ mainPanel.remove(pnlPlots); pnlUIElements.remove(pnlComboBoxes); } updateMinimumSize(); pack(); setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow()); retTimeCluster(); } else if (source.equals(cboClusters)) { Cursor cursor = this.getCursor(); this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); shapeCluster(); this.setCursor(cursor); } }
From source file:ftpclientgui.MainWindow.java
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == tmr) { this.labTime.setText(DateFormat.getTimeInstance().format(new Date())); }/*from w w w . ja va 2 s .com*/ }