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:DesktopManagerDemo.java

public void actionPerformed(ActionEvent e) {
    if (e.getSource() == m_newFrame)
        newFrame();/*from   www. j  a v a2  s. c  om*/
    else if (e.getSource() == m_eventTimer) {
        m_dmEventCanvas.render(m_myDesktopManager.getCounts());
        m_myDesktopManager.clearCounts();
    } else if (e.getSource() == m_UIBox) {
        try {
            m_UIBox.hidePopup(); //BUG WORKAROUND
            UIManager.setLookAndFeel(m_infos[m_UIBox.getSelectedIndex()].getClassName());
            SwingUtilities.updateComponentTreeUI(this);
        } catch (Exception ex) {
            System.out.println("Could not load " + m_infos[m_UIBox.getSelectedIndex()].getClassName());
        }
    }
}

From source file:GUIMediaStatistics.java

/************************************************************************
* Respond to user button presses - either browsing for a file or
* gathering format info on the current file.
************************************************************************/
public void actionPerformed(ActionEvent e) {

    /////////////////////////////////
    // Browse - use FileDialog class.
    /////////////////////////////////
    if (e.getSource() == browseButton) {
        FileDialog choice = new FileDialog(this, "Media File Choice", FileDialog.LOAD);
        if (lastDirectory != null)
            choice.setDirectory(lastDirectory);
        choice.show();/*www  .  ja  v  a  2 s.c  om*/
        String selection = choice.getFile();
        if (selection != null) {
            lastDirectory = choice.getDirectory();
            mediaField.setText("file://" + choice.getDirectory() + selection);
        }
    }
    ////////////////////////////////////////////////////////
    // Get statistics - create a MediaStatistics object and
    // monitor its progress.
    ///////////////////////////////////////////////////////
    else {
        stats = new MediaStatistics(mediaField.getText());
        monitorAndReport();
    }
}

From source file:Main.java

public TestPane() {
    setLayout(new GridBagLayout());
    label = new JLabel();
    add(label);//from w  w w  . j  a v  a2  s  .c o m
    Timer timer = new Timer(1000, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String labelText = label.getText();
            labelText += text.charAt(charIndex);
            label.setText(labelText);
            charIndex++;
            if (charIndex >= text.length()) {
                ((Timer) e.getSource()).stop();
            }
        }
    });
    timer.start();
}

From source file:jmemorize.gui.swing.panels.HistoryChartPanel.java

private JPanel buildChartChooser() {
    JComboBox comboBox = new JComboBox(new String[] { Localization.get(LC.HISTORY_RECENT),
            Localization.get(LC.HISTORY_BY_DATE), Localization.get(LC.HISTORY_BY_WEEK),
            Localization.get(LC.HISTORY_BY_MONTH), Localization.get(LC.HISTORY_BY_YEAR), });

    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox box = (JComboBox) e.getSource();
            m_mode = box.getSelectedIndex();
            updateDataSet();/*from w w w  . j  ava2 s . c o  m*/
        }
    });

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(comboBox, BorderLayout.WEST);

    return panel;
}

From source file:MenuItemChooser.java

public void actionPerformed(ActionEvent e) {
    if (e.getSource() == prev) {
        showPrevMenuItem();/*from w ww  .ja v  a 2 s . c o  m*/
    } else if (e.getSource() == next) {
        showNextMenuItem();
    } else if (e.getSource() == order) {
        placeOrder();
    } else if (e.getSource() == cancel) {
        cancelOrder();
    } else if (e.getSource() == close) {
        close();
    } else if (e.getSource() == qty) {
        updateQtyOrdered();
    }
}

From source file:net.sf.firemox.ui.wizard.Wizard.java

/**
 * triggers the OK button// w w w  . ja v  a  2s.com
 * 
 * @param event
 */
public void actionPerformed(ActionEvent event) {
    if (event.getSource() == backgroundButton) {
        // put in background this wizard
        optionAnswer = BACKGROUND_OPTION;
        MagicUIComponents.backgroundBtn.startButton(context, ability, action, this);
        setVisible(false);
        MagicUIComponents.skipButton.setEnabled(false);
    }
}

From source file:DisplayModeModel.java

public void actionPerformed(ActionEvent ev) {
    Object source = ev.getSource();
    if (source == exit) {
        device.setDisplayMode(originalDM);
        System.exit(0);/*from  w ww .j a v  a2s.  co  m*/
    } else { // if (source == changeDM)
        int index = dmList.getSelectionModel().getAnchorSelectionIndex();
        if (index >= 0) {
            DisplayModeModel model = (DisplayModeModel) dmList.getModel();
            DisplayMode dm = model.getDisplayMode(index);
            device.setDisplayMode(dm);
            setDMLabel(dm);
            setSize(new Dimension(dm.getWidth(), dm.getHeight()));
            validate();
        }
    }
}

From source file:org.kineticsystem.commons.data.demo.panels.AggregationChartPane.java

/**
 * Constructor./*  ww w  .  ja va2 s. c  om*/
 * @param source This is the source list being modified ate the same time
 *     by many threads.
 */
public AggregationChartPane(ActiveList<RandomContact> source) {

    // Define aggregators.

    GroupAggregator[] aggregators = new GroupAggregator[] { new ContactsPerContinentAggr(),
            new AvgAgePerContinentAggr(), new MaxAgePerContinentAggr(), new MinAgePerContinentAggr() };

    // Aggregator selector.

    DefaultComboBoxModel groupComboModel = new DefaultComboBoxModel(aggregators);
    final JComboBox groupCombo = new JComboBox(groupComboModel);
    groupCombo.setSelectedIndex(1);
    groupCombo.setToolTipText("Select an aggregation function.");

    // Create the dataset.

    dataset = new DefaultCategoryDataset();
    List<Country> countries = RandomContactGenerator.getCountries();
    Set<String> continents = new TreeSet<String>();

    for (Country country : countries) {
        continents.add(country.getContinent());
    }

    for (String continent : continents) {
        dataset.setValue(0, continent, "");
    }

    // Define the aggregated list.

    groups = new GroupMapping<RandomContact>(source);
    groups.setAggregator(aggregators[0]);
    groups.getTarget().addActiveListListener(this);

    // Create the chart.

    JFreeChart chart = ChartFactory.createBarChart("", "Continent", groups.getAggregator().toString(), dataset,
            PlotOrientation.VERTICAL, true, // legend?
            true, // tooltips?
            false // URLs?
    );
    final ValueAxis axis = chart.getCategoryPlot().getRangeAxis();
    axis.setAutoRange(true);
    axis.setRange(0, 250);

    ChartPanel chartPanel = new ChartPanel(chart);

    // Create the selector.

    ActionListener groupComboListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            GroupAggregator aggr = (GroupAggregator) cb.getSelectedItem();
            groups.setAggregator(aggr);
            axis.setLabel(aggr.toString());
        }
    };
    groupCombo.addActionListener(groupComboListener);

    // Layout the GUI.

    Cell cell = new Cell();

    TetrisLayout groupTableLayout = new TetrisLayout(2, 1);
    groupTableLayout.setRowWeight(0, 0);
    groupTableLayout.setRowWeight(1, 100);

    setLayout(groupTableLayout);
    add(groupCombo, cell);
    add(chartPanel, cell);
}

From source file:org.jfree.chart.demo.XYStepAreaChartDemo.java

/**
 * Change options according to settings.
 * //from  w w  w  . j av a2  s . co m
 * @param evt  the event.
 */
public void actionPerformed(final ActionEvent evt) {

    final Object source = evt.getSource();

    if (source == this.nullValuesCheckBox) {

        final boolean withNulls = this.nullValuesCheckBox.isSelected();
        for (int i = 0; i < TEST_DATA.length; i++) {
            Integer yVal = (Integer) TEST_DATA[i][1];
            if (withNulls && TEST_DATA[i].length > 2) {
                yVal = null;
            }
            this.xySeries.getDataItem(i).setY(yVal);
        }

    } else if (source == this.outlineCheckBox) {

        final XYPlot plot = (XYPlot) this.chartPanel.getChart().getPlot();
        ((XYStepAreaRenderer) plot.getRenderer()).setOutline(this.outlineCheckBox.isSelected());

    } else if (source == this.rangeBaseTextField) {

        final double val = Double.parseDouble(this.rangeBaseTextField.getText());
        final XYPlot plot = (XYPlot) this.chartPanel.getChart().getPlot();
        final XYStepAreaRenderer rend = (XYStepAreaRenderer) plot.getRenderer();
        rend.setRangeBase(val);

    } else if (source == this.orientationComboBox) {

        final XYPlot plot = (XYPlot) this.chartPanel.getChart().getPlot();
        if (this.orientationComboBox.getSelectedItem() == ORIENT_HORIZ) {
            plot.setOrientation(PlotOrientation.HORIZONTAL);
        } else if (this.orientationComboBox.getSelectedItem() == ORIENT_VERT) {
            plot.setOrientation(PlotOrientation.VERTICAL);
        }
    }

    this.chartPanel.repaint();
}

From source file:com.lfv.lanzius.application.phoneonly.PhoneOnlyView.java

public void actionPerformed(ActionEvent e) {

    if (e.getSource() == phoneOnlyContentPane.getHookButton()) {
        eventHandler.hookButtonClicked();
        updatePhoneView();// ww  w. j a v a2 s.  c o m
    }
}