Example usage for java.awt.event ActionEvent getSource

List of usage examples for java.awt.event ActionEvent getSource

Introduction

In this page you can find the example usage for java.awt.event ActionEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:gda.gui.scanplot.ScanPlot.java

private void jbInit() {
    this.setRequestFocusEnabled(true);
    legendVisible.setMnemonic(KeyEvent.VK_M);
    legendVisible.setSelected(false);/*from   www.j a v  a 2  s .c  o  m*/
    legendVisible.setToolTipText("Show the legend");
    legendVisible.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            hideLegend(!((JMenuItem) e.getSource()).isSelected());
        }
    });
    {
        if (plot instanceof ChartPanel && legendPanel instanceof Component) {
            ((ChartPanel) plot).setMinimumDrawWidth(10);
            ((ChartPanel) plot).setMinimumDrawHeight(150);
            ((Component) plot).setPreferredSize(new Dimension(800, 500));
            ((Component) legendPanel).setPreferredSize(new Dimension(100, 500));
            setLayout(new BorderLayout());
            legendVisible.setSelected(true);
        }
        hideLegend(false);
    }
}

From source file:monitor.StatsWindow.java

private void jButtonQuitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQuitActionPerformed
    Object source = evt.getSource();
    if (jButtonQuit == source) {
        dispose();//from  w  ww.jav  a2s . c  o  m
    }
}

From source file:SimpleMorph.java

/**
 * Process the actions from the buttons. The two shape buttons change the
 * geometry so that it is nearer to its corresponding key shape.
 * /*from ww w  .j  av  a2s . com*/
 * @param e
 *            ActionEvent to be processed
 */
public void actionPerformed(ActionEvent e) {
    //If its the exit button, quit the program
    if (e.getSource() == exitButton) {
        dispose();
        System.exit(0);
    }
    //If its the cube button, increase the weight
    //associated with the cube key shape and reduce
    //the other.
    else if (e.getSource() == cubeButton) {
        if (weights[0] <= 0.9) {
            weights[0] += 0.1;
            weights[1] -= 0.1;
            myMorph.setWeights(weights);
        }
    }
    //If its the pyramid button, increase the weight
    //associated with the pyramid key shape and reduce
    //the cube weight
    else if (e.getSource() == pyraButton) {
        if (weights[1] <= 0.9) {
            weights[0] -= 0.1;
            weights[1] += 0.1;
            myMorph.setWeights(weights);
        }
    }
}

From source file:presenter.MainPresenter.java

@Override
public void loadMovementsequenceFromFile(ActionEvent e) {
    JFileChooser fc = new JFileChooser();

    if (fc.showOpenDialog((Component) e.getSource()) == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        try {//from  www .j av a2  s  .  c  o  m
            this.movSeq = new Movementsequence(new Scanner(file).useDelimiter("\\A").next());
            this.emissionsequenceModel = new EmissionsequenceModel(this.movSeq);
            this.displayStatus("File was read successfully!");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

From source file:presenter.MainPresenter.java

@Override
public void loadEmissionsequenceFromFile(ActionEvent e) {
    JFileChooser fc = new JFileChooser();

    if (fc.showOpenDialog((Component) e.getSource()) == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        try {//from  w w  w  . j  a v a  2  s. co  m
            this.emissionsequenceModel = new EmissionsequenceModel(
                    new Scanner(file).useDelimiter("\\A").next());
            this.model = null;
            this.displayStatus("File was read successfully!");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

From source file:presenter.MainPresenter.java

@Override
public void saveEmissionsequenceToFile(ActionEvent e) {
    JFileChooser fc = new JFileChooser();

    if (fc.showSaveDialog((Component) e.getSource()) == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        try {/*from   ww  w . ja  va 2 s .  c  o m*/
            FileWriter fw = new FileWriter(file);
            fw.write(this.emissionsequenceModel.toString());
            fw.flush();
            fw.close();
            this.displayStatus("File was written successfully!");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

From source file:presenter.MainPresenter.java

@Override
public void saveMovementsequenceToFile(ActionEvent e) {
    JFileChooser fc = new JFileChooser();

    if (fc.showSaveDialog((Component) e.getSource()) == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        try {//  w ww  .  j  ava  2  s .com
            FileWriter fw = new FileWriter(file);
            fw.write(this.movSeq.toString());
            fw.flush();
            fw.close();
            this.displayStatus("File was written successfully!");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

From source file:SoundApplet.java

public void actionPerformed(ActionEvent event) {
    //PLAY BUTTON
    Object source = event.getSource();
    if (source == playButton) {
        //Try to get the AudioClip.
        onceClip = soundList.getClip(chosenFile);
        onceClip.play(); //Play it once.
        stopButton.setEnabled(true);//  www.ja  v  a2  s.c om
        showStatus("Playing sound " + chosenFile + ".");
        if (onceClip == null) {
            showStatus("Sound " + chosenFile + " not loaded yet.");
        }
        return;
    }

    //START LOOP BUTTON
    if (source == loopButton) {
        loopClip = soundList.getClip(chosenFile);

        looping = true;
        loopClip.loop(); //Start the sound loop.
        loopButton.setEnabled(false); //Disable loop button.
        stopButton.setEnabled(true);
        showStatus("Playing sound " + chosenFile + " continuously.");
        if (loopClip == null) {
            showStatus("Sound " + chosenFile + " not loaded yet.");
        }
        return;
    }

    //STOP LOOP BUTTON
    if (source == stopButton) {
        if (looping) {
            looping = false;
            loopClip.stop(); //Stop the sound loop.
            loopButton.setEnabled(true); //Enable start button.
        } else if (onceClip != null) {
            onceClip.stop();
        }
        stopButton.setEnabled(false);
        showStatus("Stopped playing " + chosenFile + ".");
        return;
    }
}

From source file:org.cytoscape.dyn.internal.graphMetrics.GraphMetricsResultsPanel.java

@Override
public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub
    Object source = e.getSource();
    if (source == enlargeButton) {
        enlargeChart();/*  ww w .  ja  va2 s .c  o  m*/
    } else if (source == saveChartButton) {
        SaveChartDialog dialog = new SaveChartDialog(cyActivator.getCySwingAppication().getJFrame(),
                timeSeries);
        dialog.setVisible(true);
    } else if (source == saveDataButton) {
        saveData();
    } else if (source == closeTabButton) {
        cyActivator.getCyServiceRegistrar().unregisterService(this, CytoPanelComponent.class);
    } else if (source == helpButton) {
        try {
            java.awt.Desktop.getDesktop()
                    .browse(java.net.URI.create("https://code.google.com/p/dynnetwork/wiki/DynNetworkHelp"));
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error connecting to help!", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
        //Improve  the documentation
        //DynamicNetworkHelp help = new DynamicNetworkHelp();
        //help.displayHelp();
    }
}

From source file:misc.ActionDemo.java

public void displayResult(String actionDescription, ActionEvent e) {
    String s = ("Action event detected: " + actionDescription + newline + "    Event source: " + e.getSource()
            + newline);/*from   ww w. ja  v  a 2 s  .co m*/
    textArea.append(s);
}