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

public void actionPerformed(ActionEvent e) {
    System.out.println("Selected: " + e.getActionCommand());

}

From source file:MyActionListener.java

public void actionPerformed(ActionEvent e) {
    System.out.println("Command: " + e.getActionCommand());
    int modifiers = e.getModifiers();
    System.out.println("\tALT : " + checkMod(modifiers, ActionEvent.ALT_MASK));
    System.out.println("\tCTRL : " + checkMod(modifiers, ActionEvent.CTRL_MASK));
    System.out.println("\tMETA : " + checkMod(modifiers, ActionEvent.META_MASK));
    System.out.println("\tSHIFT: " + checkMod(modifiers, ActionEvent.SHIFT_MASK));
    Object source = e.getSource();
    if (source instanceof JButton) {
        JButton jb = (JButton) source;
        System.out.println("JButton: " + jb.getText());
    }/*  w  w w  . j a v a 2 s. c om*/
}

From source file:MainClass.java

public void actionPerformed(ActionEvent ae) {
    jtf.setText(ae.getActionCommand());
}

From source file:Main.java

public void actionPerformed(ActionEvent ae) {
    String comStr = ae.getActionCommand();
    System.out.println(comStr + " Selected");
}

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

public void actionPerformed(ActionEvent actionevent) {
    if (actionevent.getActionCommand().equals("ADD_DATA")) {
        double d = 0.90000000000000002D + 0.20000000000000001D * Math.random();
        lastValue = lastValue * d;/*  w  ww. ja v  a  2s .  co  m*/
        Millisecond millisecond = new Millisecond();
        System.out.println("Now = " + millisecond.toString());
        series.add(new Millisecond(), lastValue);
    }
}

From source file:PopUpColorMenu.java

public void actionPerformed(ActionEvent e) {
    String color = e.getActionCommand();
    if (color.equals("Red"))
        selectedComponent.setBackground(Color.red);
    else if (color.equals("Green"))
        selectedComponent.setBackground(Color.green);
    else if (color.equals("Blue"))
        selectedComponent.setBackground(Color.blue);
}

From source file:MainClass.java

public void actionPerformed(ActionEvent e) {
    try {//from w  w  w . j  ava  2  s .c om
        URL url = new URL(e.getActionCommand());
        view.setPage(url);
        commandLine.setText(url.toExternalForm());
    } catch (MalformedURLException e2) {
        System.out.println("Bad URL: " + e.getActionCommand());
    } catch (java.io.IOException e2) {
    }
}

From source file:MainClass.java

public MainClass() {
    super();// w w w.j a va2 s. com
    JToolBar urlToolBar = new JToolBar();
    mURLField = new JTextField(40);
    urlToolBar.add(new JLabel("Location:"));
    urlToolBar.add(mURLField);
    frame.add(urlToolBar, BorderLayout.NORTH);

    mEditorPane = new JEditorPane();
    mEditorPane.setEditable(false);
    frame.add(new JScrollPane(mEditorPane), BorderLayout.CENTER);

    openURL("http://www.java2s.com");

    mURLField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            openURL(ae.getActionCommand());
        }
    });

    mEditorPane.addHyperlinkListener(new LinkActivator());

    setSize(500, 600);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:ToolbarFrame1.java

public ToolbarFrame1() {
    super("Toolbar Example (AWT)");
    setSize(450, 250);/*w  ww  .  ja v  a  2  s. c  om*/
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    ActionListener printListener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            System.out.println(ae.getActionCommand());
        }
    };

    Panel toolbar = new Panel();
    toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));

    cutButton = new Button("Cut");
    cutButton.addActionListener(printListener);
    toolbar.add(cutButton);

    copyButton = new Button("Copy");
    copyButton.addActionListener(printListener);
    toolbar.add(copyButton);

    pasteButton = new Button("Paste");
    pasteButton.addActionListener(printListener);
    toolbar.add(pasteButton);

    add(toolbar, BorderLayout.NORTH);
}

From source file:MainClass.java

public void actionPerformed(ActionEvent actionEvent) {
    System.out.println("Selected: " + actionEvent.getActionCommand());
}