Example usage for java.awt.event ActionListener interface-usage

List of usage examples for java.awt.event ActionListener interface-usage

Introduction

In this page you can find the example usage for java.awt.event ActionListener interface-usage.

Usage

From source file Main.java

public class Main implements ActionListener {
    Timer t = new Timer(1000, this);

    Main() {
        t.start();
    }

From source file MyActionListener.java

class MyActionListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        System.out.println("Command: " + e.getActionCommand());
        Object source = e.getSource();
        if (source instanceof JButton) {
            JButton jb = (JButton) source;

From source file MyButton.java

class MyButton extends JButton implements ActionListener {

    public MyButton(String text) {
        super.setText(text);
        addActionListener(this);
    }

From source file CheckBox.java

public class CheckBox extends JFrame implements ActionListener {

    public CheckBox() {
        JCheckBox checkbox = new JCheckBox("Show Title", true);
        checkbox.addActionListener(this);
        add(checkbox);

From source file Main.java

public class Main extends JFrame implements ActionListener {

    public Main() {
        JCheckBox checkbox = new JCheckBox("Show Title", true);
        checkbox.addActionListener(this);
        add(checkbox);

From source file MyActionListener.java

class MyActionListener implements ActionListener {
    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));

From source file MainClass.java

public class MainClass extends JPanel implements ActionListener {
    JTextField jtf = new JTextField(15);

    public MainClass() {

        add(jtf);

From source file ButtonListener.java

class ButtonListener implements ActionListener {
    ButtonListener() {
    }

    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand().equals("Button1")) {

From source file MainClass.java

public class MainClass extends JFrame implements ActionListener {
    private JButton button1 = new JButton("Click Me!");
    private int clickCount = 0;

    public static void main(String[] args) {
        new MainClass();

From source file ButtonListener.java

class ButtonListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        JButton o = (JButton) e.getSource();
        String label = o.getText();
        System.out.println(label + " button clicked");
    }