Example usage for java.awt.event ActionEvent getActionCommand

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

Introduction

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

Prototype

public String getActionCommand() 

Source Link

Document

Returns the command string associated with this action.

Usage

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

/**
 * Handles a click on the button by adding new (random) data.
 *
 * @param e  the action event./*from w  ww .j  a  va2  s .  c  o m*/
 */
public void actionPerformed(ActionEvent e) {

    if (e.getActionCommand().equals("ADD_DATASET")) {
        if (this.secondaryDatasetIndex < 19) {
            this.secondaryDatasetIndex++;
            this.plot.setSecondaryDataset(this.secondaryDatasetIndex,
                    createRandomDataset("S" + this.secondaryDatasetIndex));
            this.plot.setSecondaryRenderer(this.secondaryDatasetIndex, new StandardXYItemRenderer());
        }
    } else if (e.getActionCommand().equals("REMOVE_DATASET")) {
        if (this.secondaryDatasetIndex >= 0) {
            this.plot.setSecondaryDataset(this.secondaryDatasetIndex, null);
            this.plot.setSecondaryRenderer(this.secondaryDatasetIndex, null);
            this.secondaryDatasetIndex--;
        }
    }

}

From source file:InternalFrameDemo.java

public void actionPerformed(ActionEvent e) {
    if ("new".equals(e.getActionCommand())) { // new
        createFrame();/*from   w w  w  .  j  a v  a  2s  . co  m*/
    } else { // quit
        quit();
    }
}

From source file:ColorPicker3.java

public void actionPerformed(ActionEvent ae) {
    int val = 100 - Integer.parseInt(ae.getActionCommand());
    getColorSelectionModel().setSelectedColor(grays[(int) (val * 2.55)]);
}

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

/**
 * Handles a click on the button by adding new (random) data.
 *
 * @param e  the action event.//from w w  w  .  j a  v  a  2s. c  om
 */
public void actionPerformed(final ActionEvent e) {

    if (e.getActionCommand().equals("ADD_DATASET")) {
        if (this.datasetIndex < 20) {
            this.datasetIndex++;
            this.plot.setDataset(this.datasetIndex, createRandomDataset("S" + this.datasetIndex));
            this.plot.setRenderer(this.datasetIndex, new StandardXYItemRenderer());
        }
    } else if (e.getActionCommand().equals("REMOVE_DATASET")) {
        if (this.datasetIndex >= 1) {
            this.plot.setDataset(this.datasetIndex, null);
            this.plot.setRenderer(this.datasetIndex, null);
            this.datasetIndex--;
        }
    }

}

From source file:it.unibas.spicygui.controllo.provider.composition.MyPopupProviderConnectionChainComposition.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(SET_ROOT)) {
        ////            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(Costanti.class, Costanti.SHOW_HIDE_INFO_CONNECTION));
        ////            Widget popUpMenu = null;
        ////            for (Widget widget : menu.getChildren()) {
        ////                if (widget instanceof VMDNodeWidget) {
        ////                    popUpMenu = widget;
        ////                    break;
        ////                }
        ////            }
        ////            if (popUpMenu != null) {
        ////                popUpMenu.removeFromParent();
        ////                scene.validate();
        ////            } else {
        //            showInfo();
        ////            }
    } else {/*from ww w.  j  a  v  a  2  s. c o  m*/
        deleteConnection();
    }
}

From source file:it.unibas.spicygui.controllo.provider.MyPopupProviderConnectionMappingTask.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(SHOW)) {
        ////            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(Costanti.class, Costanti.SHOW_HIDE_INFO_CONNECTION));
        ////            Widget popUpMenu = null;
        ////            for (Widget widget : menu.getChildren()) {
        ////                if (widget instanceof VMDNodeWidget) {
        ////                    popUpMenu = widget;
        ////                    break;
        ////                }
        ////            }
        ////            if (popUpMenu != null) {
        ////                popUpMenu.removeFromParent();
        ////                scene.validate();
        ////            } else {
        //            showInfo();
        ////            }
    } else {/*from  www  . ja  v a2  s  .  c  om*/
        deleteConnection();
    }
}

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

/**
 * Handles a click on the button by adding new (random) data.
 *
 * @param e  the action event./*from  www  .j  a  v a  2 s .c  o  m*/
 */
public void actionPerformed(final ActionEvent e) {

    if (e.getActionCommand().equals("ADD_DATASET")) {
        if (this.secondaryDatasetIndex < 20) {
            this.secondaryDatasetIndex++;
            this.plot.setDataset(this.secondaryDatasetIndex,
                    createRandomDataset("S" + this.secondaryDatasetIndex));
            //                this.plot.setRenderer(
            //                  this.secondaryDatasetIndex, new LineAndShapeRenderer(LineAndShapeRenderer.LINES)
            //            );
        }
    } else if (e.getActionCommand().equals("REMOVE_DATASET")) {
        if (this.secondaryDatasetIndex > 0) {
            this.plot.setDataset(this.secondaryDatasetIndex, null);
            this.plot.setRenderer(this.secondaryDatasetIndex, null);
            this.secondaryDatasetIndex--;
        }
    }

}

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

public void actionPerformed(ActionEvent actionevent) {
    if (actionevent.getActionCommand().equals("fontButton.clicked"))
        displayFontDialog();//from ww w . java2  s  .  co  m
    if (actionevent.getActionCommand().equals("combo1.changed"))
        handleCombo1Change();
    if (actionevent.getActionCommand().equals("combo2.changed"))
        handleCombo2Change();
    if (actionevent.getActionCommand().equals("combo3.changed"))
        handleCombo3Change();
}

From source file:CheckBoxMenuItemExample.java

public CheckBoxMenuItemExample() {
    menuBar = new JMenuBar();
    JMenu justifyMenu = new JMenu("Justify");
    ActionListener actionPrinter = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                pane.getStyledDocument().insertString(0, "Action [" + e.getActionCommand() + "] performed!\n",
                        null);/*w  ww  .  jav  a 2  s .  c  om*/
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    };
    JCheckBoxMenuItem leftJustify = new JCheckBoxMenuItem("Left", new ImageIcon("1.gif"));
    leftJustify.setHorizontalTextPosition(JMenuItem.RIGHT);
    leftJustify
            .setAccelerator(KeyStroke.getKeyStroke('L', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    leftJustify.addActionListener(actionPrinter);
    JCheckBoxMenuItem rightJustify = new JCheckBoxMenuItem("Right", new ImageIcon("2.gif"));
    rightJustify.setHorizontalTextPosition(JMenuItem.RIGHT);
    rightJustify
            .setAccelerator(KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    rightJustify.addActionListener(actionPrinter);
    JCheckBoxMenuItem centerJustify = new JCheckBoxMenuItem("Center", new ImageIcon("3.gif"));
    centerJustify.setHorizontalTextPosition(JMenuItem.RIGHT);
    centerJustify
            .setAccelerator(KeyStroke.getKeyStroke('M', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    centerJustify.addActionListener(actionPrinter);
    JCheckBoxMenuItem fullJustify = new JCheckBoxMenuItem("Full", new ImageIcon("4.gif"));
    fullJustify.setHorizontalTextPosition(JMenuItem.RIGHT);
    fullJustify
            .setAccelerator(KeyStroke.getKeyStroke('F', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fullJustify.addActionListener(actionPrinter);

    justifyMenu.add(leftJustify);
    justifyMenu.add(rightJustify);
    justifyMenu.add(centerJustify);
    justifyMenu.add(fullJustify);

    menuBar.add(justifyMenu);
    menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));

}

From source file:DynamicDataDemo.java

/**
 * Handles a click on the button by adding new (random) data.
 *
 * @param e  the action event.// ww w . j a  va2s  .  c o  m
 */
public void actionPerformed(final ActionEvent e) {
    if (e.getActionCommand().equals("ADD_DATA")) {
        final double factor = 0.90 + 0.2 * Math.random();
        this.lastValue = this.lastValue * factor;
        final Millisecond now = new Millisecond();
        System.out.println("Now = " + now.toString());
        this.series.add(new Millisecond(), this.lastValue);
    }
}