List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java
private void changePositionOrderAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changePositionOrderAction final MultipleSelectionModel<Position> selection = positionsFxList.getSelectionModel(); final int index = selection.getSelectedIndex(); Position selectedItem = selection.getSelectedItem(); if (index < 0) return;/*from w w w. j a v a2 s. co m*/ if (evt.getSource() == moveUpButton) { if (index == 0) return; // Don't move at the beginning document.moveUp(selectedItem); Platform.runLater(new Runnable() { @Override public void run() { Position removed = positions.remove(index); positions.add(index - 1, removed); selection.select(index - 1); } }); } else { if (index == positions.size() - 1) return; // Don't move at the end document.moveDown(selectedItem); Platform.runLater(new Runnable() { @Override public void run() { Position removed = positions.remove(index); positions.add(index + 1, removed); selection.select(index + 1); } }); } }
From source file:edu.purdue.cc.bionet.ui.ClusteringDisplayPanel.java
/** * The actionPerformed method of the ActionListener interface. Performs * cluster recalculation when the 'recalculate' button is clicked. * /* ww w.j a va2 s . co m*/ * @param e The event which triggered this action. */ public void actionPerformed(ActionEvent e) { Logger logger = Logger.getLogger(getClass()); Language language = Settings.getLanguage(); Object source = e.getSource(); if (source == this.recomputeMenuItem) { // don't change the groups, just trigger the clusterer this.setSampleGroups(this.getSampleGroups()); } else if (source == this.chooseSampleGroupsMenuItem) { // Choose sample groups. Component frame = this; while (!(frame instanceof Frame) && frame != null) { frame = frame.getParent(); } Collection<SampleGroup> groups = SampleGroupDialog.showInputDialog((Frame) frame, Settings.getLanguage().get("Choose groups"), this.samples); if (groups != null) { if (this.getSampleGroups() != null) { for (SampleGroup group : this.getSampleGroups()) { logger.debug(group.toString()); for (Sample sample : group) { logger.debug("\t" + sample.toString()); } } } this.setSampleGroups(groups); } } else if (source == this.removeSampleGroupsMenuItem) { Collection<SampleGroup> groups = new ArrayList<SampleGroup>(); groups.add(new SampleGroup("", this.samples)); this.setSampleGroups(groups); } }
From source file:projects.wdlf47tuc.ProcessAllSwathcal.java
/** * Main entry point.//from ww w . ja v a 2 s.c o m * * @param args * * @throws IOException * */ public ProcessAllSwathcal() { // Path to AllSwathcal.dat file File allSwathcal = new File( "/home/nrowell/Astronomy/Data/47_Tuc/Kalirai_2012/UVIS/www.stsci.edu/~jkalirai/47Tuc/AllSwathcal.dat"); // Read file contents into the List try (BufferedReader in = new BufferedReader(new FileReader(allSwathcal))) { String sourceStr; while ((sourceStr = in.readLine()) != null) { Source source = Source.parseSource(sourceStr); if (source != null) { allSources.add(source); } } } catch (IOException e) { } logger.info("Parsed " + allSources.size() + " Sources from AllSwathcal.dat"); // Initialise chart cmdPanel = new ChartPanel(updateDataAndPlotCmd(allSources)); cmdPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { // Capture mouse click location, transform to graph coordinates and add // a point to the polygonal selection box. Point2D p = cmdPanel.translateScreenToJava2D(e.getTrigger().getPoint()); Rectangle2D plotArea = cmdPanel.getScreenDataArea(); XYPlot plot = (XYPlot) cmdPanel.getChart().getPlot(); double chartX = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge()); double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge()); points.add(new double[] { chartX, chartY }); cmdPanel.setChart(plotCmd()); } @Override public void chartMouseMoved(ChartMouseEvent arg0) { } }); // Create colour combo boxes final JComboBox<Filter> magComboBox = new JComboBox<Filter>(filters); final JComboBox<Filter> col1ComboBox = new JComboBox<Filter>(filters); final JComboBox<Filter> col2ComboBox = new JComboBox<Filter>(filters); // Set initial values magComboBox.setSelectedItem(magFilter); col1ComboBox.setSelectedItem(col1Filter); col2ComboBox.setSelectedItem(col2Filter); // Create an action listener for these ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (evt.getSource() == magComboBox) { magFilter = (Filter) magComboBox.getSelectedItem(); } if (evt.getSource() == col1ComboBox) { col1Filter = (Filter) col1ComboBox.getSelectedItem(); } if (evt.getSource() == col2ComboBox) { col2Filter = (Filter) col2ComboBox.getSelectedItem(); } // Changed colour(s), so reset selection box coordinates points.clear(); cmdPanel.setChart(updateDataAndPlotCmd(allSources)); } }; magComboBox.addActionListener(al); col1ComboBox.addActionListener(al); col2ComboBox.addActionListener(al); // Add a bit of padding to space things out magComboBox.setBorder(new EmptyBorder(5, 5, 5, 5)); col1ComboBox.setBorder(new EmptyBorder(5, 5, 5, 5)); col2ComboBox.setBorder(new EmptyBorder(5, 5, 5, 5)); // Set up statistic sliders final JSlider magErrMaxSlider = GuiUtil.buildSlider(magErrorRangeMin, magErrorRangeMax, 3, "%3.3f"); final JSlider chi2MaxSlider = GuiUtil.buildSlider(chi2RangeMin, chi2RangeMax, 3, "%3.3f"); final JSlider sharpMinSlider = GuiUtil.buildSlider(sharpRangeMin, sharpRangeMax, 3, "%3.3f"); final JSlider sharpMaxSlider = GuiUtil.buildSlider(sharpRangeMin, sharpRangeMax, 3, "%3.3f"); // Set intial values magErrMaxSlider.setValue( (int) Math.rint(100.0 * (magErrMax - magErrorRangeMin) / (magErrorRangeMax - magErrorRangeMin))); chi2MaxSlider.setValue((int) Math.rint(100.0 * (chi2Max - chi2RangeMin) / (chi2RangeMax - chi2RangeMin))); sharpMinSlider .setValue((int) Math.rint(100.0 * (sharpMin - sharpRangeMin) / (sharpRangeMax - sharpRangeMin))); sharpMaxSlider .setValue((int) Math.rint(100.0 * (sharpMax - sharpRangeMin) / (sharpRangeMax - sharpRangeMin))); // Set labels & initial values final JLabel magErrMaxLabel = new JLabel(getMagErrMaxLabel()); final JLabel chi2MaxLabel = new JLabel(getChi2MaxLabel()); final JLabel sharpMinLabel = new JLabel(getSharpMinLabel()); final JLabel sharpMaxLabel = new JLabel(getSharpMaxLabel()); // Create a change listener fot these ChangeListener cl = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (source == magErrMaxSlider) { // Compute max mag error from slider position double newMagErrMax = magErrorRangeMin + (magErrorRangeMax - magErrorRangeMin) * (source.getValue() / 100.0); magErrMax = newMagErrMax; magErrMaxLabel.setText(getMagErrMaxLabel()); } if (source == chi2MaxSlider) { // Compute Chi2 max from slider position double newChi2Max = chi2RangeMin + (chi2RangeMax - chi2RangeMin) * (source.getValue() / 100.0); chi2Max = newChi2Max; chi2MaxLabel.setText(getChi2MaxLabel()); } if (source == sharpMinSlider) { // Compute sharp min from slider position double newSharpMin = sharpRangeMin + (sharpRangeMax - sharpRangeMin) * (source.getValue() / 100.0); sharpMin = newSharpMin; sharpMinLabel.setText(getSharpMinLabel()); } if (source == sharpMaxSlider) { // Compute sharp max from slider position double newSharpMax = sharpRangeMin + (sharpRangeMax - sharpRangeMin) * (source.getValue() / 100.0); sharpMax = newSharpMax; sharpMaxLabel.setText(getSharpMaxLabel()); } cmdPanel.setChart(updateDataAndPlotCmd(allSources)); } }; magErrMaxSlider.addChangeListener(cl); chi2MaxSlider.addChangeListener(cl); sharpMinSlider.addChangeListener(cl); sharpMaxSlider.addChangeListener(cl); // Add a bit of padding to space things out magErrMaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); chi2MaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); sharpMinSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); sharpMaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); // Text field to store distance modulus final JTextField distanceModulusField = new JTextField(Double.toString(mu)); distanceModulusField.setBorder(new EmptyBorder(5, 5, 5, 5)); Border compound = BorderFactory.createCompoundBorder(new LineBorder(this.getBackground(), 5), BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); final JButton lfButton = new JButton("Luminosity function for selection"); lfButton.setBorder(compound); lfButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Read distance modulus field try { double mu_new = Double.parseDouble(distanceModulusField.getText()); mu = mu_new; } catch (NullPointerException | NumberFormatException ex) { JOptionPane.showMessageDialog(lfButton, "Error parsing the distance modulus: " + ex.getMessage(), "Distance Modulus Error", JOptionPane.ERROR_MESSAGE); return; } if (boxedSources.isEmpty()) { JOptionPane.showMessageDialog(lfButton, "No sources are currently selected!", "Selection Error", JOptionPane.ERROR_MESSAGE); } else { computeAndPlotLuminosityFunction(boxedSources); } } }); final JButton clearSelectionButton = new JButton("Clear selection"); clearSelectionButton.setBorder(compound); clearSelectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { points.clear(); cmdPanel.setChart(plotCmd()); } }); JPanel controls = new JPanel(new GridLayout(9, 2)); controls.setBorder(new EmptyBorder(10, 10, 10, 10)); controls.add(new JLabel("Magnitude = ")); controls.add(magComboBox); controls.add(new JLabel("Colour 1 = ")); controls.add(col1ComboBox); controls.add(new JLabel("Colour 2 = ")); controls.add(col2ComboBox); controls.add(magErrMaxLabel); controls.add(magErrMaxSlider); controls.add(chi2MaxLabel); controls.add(chi2MaxSlider); controls.add(sharpMinLabel); controls.add(sharpMinSlider); controls.add(sharpMaxLabel); controls.add(sharpMaxSlider); controls.add(new JLabel("Adopted distance modulus = ")); controls.add(distanceModulusField); controls.add(lfButton); controls.add(clearSelectionButton); this.setLayout(new BorderLayout()); this.add(cmdPanel, BorderLayout.CENTER); this.add(controls, BorderLayout.SOUTH); this.validate(); }
From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java
@Override public void actionPerformed(ActionEvent e) { JButton btn = (JButton) e.getSource(); if (btn.getName().equals(ResourceBundleHelper.getMessageString("videoTab.enter"))) { doEnter();//from w w w. j ava 2 s. co m } else if (btn.getName().equals(ResourceBundleHelper.getMessageString("videoTab.load"))) { doLoad(); } else if (btn.getName().equals(ResourceBundleHelper.getMessageString("videoTab.close"))) { doClose(); } else if (btn.getName().equals(ResourceBundleHelper.getMessageString("videoTab.save"))) { // Saving after testing the regex by clicking on enter saveConfig(); } }
From source file:TextureByReference.java
public void actionPerformed(ActionEvent e) { Object o = e.getSource(); // for the animation button if (o == animationB) { if (animate.getEnable()) { animate.setEnable(false);/*from w w w . jav a 2 s.co m*/ animationB.setText("start animation"); } else { animate.setEnable(true); animationB.setText(" stop animation "); } } // for the texByRef button else if (o == texByRef && texByRef.isSelected()) { animate.setByReference(true); } // texByCopy button else if (o == texByCopy && texByCopy.isSelected()) { animate.setByReference(false); } // yUp button else if (o == yUp && yUp.isSelected()) { animate.setYUp(true); } // ydown button else if (o == yDown && yDown.isSelected()) { animate.setYUp(false); } //geomByRef button else if (o == geomByRef) { tetra.setByReference(true); } // geomByCopy button else if (o == geomByCopy) { tetra.setByReference(false); } // TYPE_INT_ARGB else if (o == imgIntARGB) { animate.setImageType(BufferedImage.TYPE_INT_ARGB); } // TYPE_4BYTE_ABGR else if (o == img4ByteABGR) { animate.setImageType(BufferedImage.TYPE_4BYTE_ABGR); } // TYPE_3BYTE_BGR else if (o == img3ByteBGR) { animate.setImageType(BufferedImage.TYPE_3BYTE_BGR); } // TYPE_CUSTOM RGBA else if (o == imgCustomRGBA) { animate.setImageTypeCustomRGBA(); } // TYPE_CUSTOM RGB else if (o == imgCustomRGB) { animate.setImageTypeCustomRGB(); } }
From source file:net.itransformers.topologyviewer.gui.GraphViewerPanel.java
private JComboBox createHopsCombo() { HopsType hopsType = viewerConfig.getHops(); JComboBox hopsCombo = new JComboBox(); if (hopsType == null) return hopsCombo; String[] hopsArr = hopsType.getValue().split(","); for (String hops : hopsArr) { final int hopsInt = Integer.parseInt(hops); hopsCombo.addItem(hopsInt);// w w w . ja va 2 s . com } hopsCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Integer hops = (Integer) ((JComboBox) e.getSource()).getSelectedItem(); currentHops = hops; } }); currentHops = Integer.valueOf(hopsType.getSelected()); hopsCombo.setSelectedItem(currentHops); return hopsCombo; }
From source file:fr.jmmc.jmcs.logging.LogbackGui.java
/** * Process any comboBox change event (level) to update Logger's state * @param ae action event/* w ww. j a v a 2s . c om*/ */ @Override public void actionPerformed(final ActionEvent ae) { if (ae.getSource() == jComboBoxLevel) { if (_doAutoUpdateLogger) { if (_currentLogger != null) { final Level level = Level.toLevel((String) jComboBoxLevel.getSelectedItem(), null); // intercept known bug in JUL-to-SLF4J: try { _currentLogger.setLevel(level); } catch (RuntimeException re) { _logger.info("setLevel failure:", re); } _logger.warn("Updated level for Logger [{}] to [{}]", _currentLogger.getName(), _currentLogger.getLevel()); // update form: processLoggerSelection(_currentLogger); } } } }
From source file:kolacer.Kolacer.java
private void jBut_barva_grad_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBut_barva_grad_ActionPerformed JButton sauc = (JButton) evt.getSource(); short gradID = -1; int saucHash = sauc.hashCode(); if (saucHash == jBut_barva_grad_A.hashCode()) { gradID = 0;/* ww w . j a va2 s. c o m*/ } else if (saucHash == jBut_barva_grad_B.hashCode()) { gradID = 1; } else { System.err.println("Invailt gradient color change from: " + sauc.getName()); return; } Color bar = ziskejBarvu(false); if (bar == null) return; switch (gradID) { case 0: jBut_barva_grad_A.setBackground(barvaGradA = bar); break; case 1: jBut_barva_grad_B.setBackground(barvaGradB = bar); break; } }
From source file:temp1.JFrame1.java
private void jToggleButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton4ActionPerformed AbstractButton abstractButton = (AbstractButton) evt.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (!selected) c1 = selected;//from w ww .j a v a 2s . co m if (selected) c1 = selected; }
From source file:temp1.JFrame1.java
private void jToggleButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton5ActionPerformed AbstractButton abstractButton = (AbstractButton) evt.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (!selected) c2 = selected;/*from w w w . j a va2s. c o m*/ if (selected) c2 = selected; }