List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:edu.ku.brc.af.ui.db.ViewBasedDisplayFrame.java
public void actionPerformed(ActionEvent e) { if (vbdaa != null) { if (e.getSource() == okBtn) { vbdaa.okPressed(this); } else if (e.getSource() == cancelBtn) { vbdaa.cancelPressed(this); } else if (e.getSource() == applyBtn) { vbdaa.applyPressed(this); } else if (e.getSource() == helpBtn) { vbdaa.helpPressed(this); }/* w ww .j ava 2s .co m*/ } }
From source file:ComboBoxes.java
public void init() { for (int i = 0; i < 4; i++) c.addItem(description[count++]); t.setEditable(false);/*from ww w . j ava2s . c o m*/ b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (count < description.length) c.addItem(description[count++]); } }); c.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { t.setText("index: " + c.getSelectedIndex() + " " + ((JComboBox) e.getSource()).getSelectedItem()); } }); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(t); cp.add(c); cp.add(b); }
From source file:de.burrotinto.jKabel.dispalyAS.DisplayAAS.java
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == exit) { System.exit(0);/* w ww . ja va2 s. co m*/ } if (db != null) { if (e.getSource() == edit) { remove(center); center = bearbeitenPanel; menuBar.add(trommeln); menuBar.updateUI(); getContentPane().add(center, BorderLayout.CENTER); } else if (e.getSource() == search) { remove(center); center = new SearchAAS(db); menuBar.remove(trommeln); getContentPane().add(center, BorderLayout.CENTER); } repaint(); revalidate(); } }
From source file:pt.lsts.neptus.console.bathymLayer.TidePanel.java
@Override public void initSubPanel() { storedMenuPath = I18n.text("Tools") + ">" + I18n.text("Tides") + ">" + I18n.textf("Using '%file'", GeneralPreferences.tidesFile.getName()); tidesItem = addMenuItem(storedMenuPath, null, new ActionListener() { @Override// w w w . j av a2 s.c o m public void actionPerformed(ActionEvent e) { JMenuItem menu = (JMenuItem) e.getSource(); Thread t = new Thread("Tide chooser") { @Override public void run() { try { File usedTidesSource = GeneralPreferences.tidesFile; String currentSource = usedTidesSource == null || !usedTidesSource.exists() ? null : usedTidesSource.getName(); Date startDate = new Date(System.currentTimeMillis() - 2 * DateTimeUtil.DAY); Date endDate = new Date(System.currentTimeMillis() + 3 * DateTimeUtil.DAY); String harbor = TidePredictionFactory.showTidesSourceChooserGuiPopup(getConsole(), currentSource, startDate, endDate); if (harbor != null && !harbor.isEmpty() && TidePredictionFactory.getTidesSourceFileFrom(harbor).exists()) { GeneralPreferences.tidesFile = TidePredictionFactory.getTidesSourceFileFrom(harbor); GeneralPreferences.saveProperties(); preferencesUpdated(); // Force the tide file reload TidePredictionFactory.getTideLevel(System.currentTimeMillis()); } } catch (Exception e) { e.printStackTrace(); } finally { menu.setEnabled(true); } } }; t.setDaemon(true); menu.setEnabled(false); t.run(); } }); // tidesItem.setEnabled(false); addMenuItem(I18n.text("Tools") + ">" + I18n.text("Tides") + ">" + I18n.text("Update Predictions"), null, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JMenuItem menu = (JMenuItem) e.getSource(); Thread t = new Thread("Tide fetcher") { public void run() { try { String harbor = TidePredictionFactory.fetchData(getConsole()); if (harbor != null && !harbor.isEmpty()) { File used = GeneralPreferences.tidesFile; File f = new File(ConfigFetch.getConfFolder() + "/tides/" + harbor + "." + TidePredictionFactory.defaultTideFormat); if (f.exists() && !f.getAbsolutePath().equals(used.getAbsolutePath())) { int resp = GuiUtils.confirmDialog(getConsole(), I18n.text("Tide Predictions"), I18n.textf( "The selected location does not match the current location in use (%harbor). Do you wish to set the current location as %selection?", used.getName(), harbor + "." + TidePredictionFactory.defaultTideFormat), ModalityType.DOCUMENT_MODAL); if (resp == JOptionPane.YES_OPTION) { GeneralPreferences.tidesFile = f; GeneralPreferences.saveProperties(); preferencesUpdated(); // Force the tide file reload TidePredictionFactory.getTideLevel(System.currentTimeMillis()); } } } } catch (Exception e) { e.printStackTrace(); } finally { menu.setEnabled(true); } }; }; t.setDaemon(true); menu.setEnabled(false); t.start(); } }); ts = new TimeSeries(I18n.text("Tide level")); tsc.addSeries(ts); for (double i = -12; i < 12; i += 0.25) { Date d = new Date(System.currentTimeMillis() + (long) (i * 1000 * 3600)); ts.addOrUpdate(new Millisecond(d), TidePredictionFactory.getTideLevel(d)); } timeSeriesChart.getXYPlot().addDomainMarker(marker); levelMarker.setValue(TidePredictionFactory.getTideLevel(new Date())); timeSeriesChart.getXYPlot().addRangeMarker(levelMarker); }
From source file:cn.edu.tsinghua.gui.HistogramDemo.java
/** * Handle button clicks.//ww w . ja va2 s . com */ public void actionPerformed(ActionEvent e) { JButton b = (JButton) e.getSource(); if (b == reset) { target = source; } else if (b == equal) { target = equalize(); } else if (b == norm) { target = normalize(); } else if (b == piece) { target = piecewise(); } canvas.set(target); graph.plot(getMultiHistogram(target)); }
From source file:ui.results.ResultChartPanel.java
@Override public void actionPerformed(ActionEvent e) { String command = ((JRadioButton) e.getSource()).getActionCommand(); CategoryPlot plot = (CategoryPlot) chart.getPlot(); if (command.equals("line chart") || command.equals("bar chart")) { // Change the chart by a line chart if (command.equals("line chart")) { plot.setRenderer(0, lineRenderer0); plot.setRenderer(1, lineRenderer1); plot.setRenderer(2, lineRenderer2); plot.setDataset(0, lower);/* ww w . ja va 2s. co m*/ plot.setDataset(1, dataset); plot.setDataset(2, upper); } else if (command.equals("bar chart")) { plot.setRenderer(null); plot.setRenderer(1, barRenderer); plot.setRenderer(2, null); plot.setDataset(0, null); plot.setDataset(1, dataset); plot.setDataset(2, null); logger.debug("Number of datasets: " + plot.getDatasetCount()); } } }
From source file:net.aepik.alasca.gui.util.LoadFileFrame.java
/** * Perform action on event for this object. *///from w w w . j a v a2s .c om public void actionPerformed(ActionEvent e) { Object o = e.getSource(); if (o == boutonOpenFile) { JFileChooser jfcProgramme = new JFileChooser("."); jfcProgramme.setMultiSelectionEnabled(false); jfcProgramme.setDialogTitle("Selectionner un fichier"); jfcProgramme.setApproveButtonText("Selectionner"); jfcProgramme.setApproveButtonToolTipText("Cliquer apres avoir selectionn un fichier"); jfcProgramme.setAcceptAllFileFilterUsed(false); if (jfcProgramme.showDialog(this, null) == JFileChooser.APPROVE_OPTION) { try { filename.setText(jfcProgramme.getSelectedFile().getCanonicalPath()); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Erreur de nom de fichier.", "Erreur", JOptionPane.ERROR_MESSAGE); } } } if (o == boutonOk && filename.getText().length() != 0) { if (!this.loadFile(filename.getText(), (String) this.syntaxes.getSelectedItem())) { JOptionPane.showMessageDialog(this, this.getErrorMessage(), "Erreur", JOptionPane.ERROR_MESSAGE); } else { windowClosing(null); } } if (o == boutonAnnuler) { windowClosing(null); } }
From source file:SoundExample.java
public void actionPerformed(ActionEvent event) { //PLAY BUTTON Object source = event.getSource(); if (source == playOnce) { if (onceClip == null) { //Try to get the AudioClip. onceClip = soundList.getClip(onceFile); }//from w w w. ja v a 2 s .c o m if (onceClip != null) { //If the sound is loaded: onceClip.play(); //Play it once. showStatus("Playing sound " + onceFile + "."); } else { showStatus("Sound " + onceFile + " not loaded yet."); } return; } //START LOOP BUTTON if (source == startLoop) { if (loopClip == null) { //Try to get the AudioClip. loopClip = soundList.getClip(loopFile); } if (loopClip != null) { //If the sound is loaded: looping = true; loopClip.loop(); //Start the sound loop. stopLoop.setEnabled(true); //Enable stop button. startLoop.setEnabled(false); //Disable start button. showStatus("Playing sound " + loopFile + " continuously."); } else { showStatus("Sound " + loopFile + " not loaded yet."); } return; } //STOP LOOP BUTTON if (source == stopLoop) { if (looping) { looping = false; loopClip.stop(); //Stop the sound loop. startLoop.setEnabled(true); //Enable start button. stopLoop.setEnabled(false); //Disable stop button. } showStatus("Stopped playing sound " + loopFile + "."); return; } //RELOAD BUTTON if (source == reload) { if (looping) { //Stop the sound loop. looping = false; loopClip.stop(); startLoop.setEnabled(true); //Enable start button. stopLoop.setEnabled(false); //Disable stop button. } loopClip = null; //Reset AudioClip to null. onceClip = null; //Reset AudioClip to null. startLoadingSounds(); showStatus("Reloading all sounds."); return; } }
From source file:MenuShortcuts.java
/** Handle action events. */ public void actionPerformed(ActionEvent evt) { // System.out.println("Event " + evt); String cmd;/*from ww w .j av a2s .c o m*/ if ((cmd = evt.getActionCommand()) == null) System.out.println("You chose a menu shortcut"); else System.out.println("You chose " + cmd); Object cmp = evt.getSource(); // System.out.println("Source " + cmp); if (cmp == exitItem) System.exit(0); }
From source file:sanger.team16.gui.genevar.eqtl.snp.CisEQTLSNPPane2.java
private void cisSNPPane2ActionPerformed(ActionEvent e) { if (e.getSource() == bRemove) this.ui.removeCurrentNode(); else if (e.getSource() == bSubmit) new CisSNPPane2ProgressBar().execute(); }