List of usage examples for java.awt.event ActionListener ActionListener
ActionListener
From source file:MainClass.java
public static void main(String args[]) { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Hello World Timer"); }//from w ww . j av a 2 s .co m }; Timer timer = new Timer(500, actionListener); timer.start(); }
From source file:Main.java
public static void main(String[] args) { JComboBox<String> emptyBox = new JComboBox<String>(); emptyBox.addActionListener(new ActionListener() { @Override//from w w w.j ava2 s. c o m public void actionPerformed(ActionEvent e) { Thread.dumpStack(); } }); emptyBox.addItem("test"); }
From source file:TimerSample.java
public static void main(String args[]) { new JFrame().setVisible(true); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Hello World Timer"); }//ww w . j a v a2s . c o m }; Timer timer = new Timer(500, actionListener); timer.start(); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton("Test"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Button pressed"); }//www . j a v a 2 s . c o m }); JOptionPane.showMessageDialog(null, button); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton("Text Button"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { String command = actionEvent.getActionCommand(); System.out.println("Selected: " + command); }/*w ww .j a va2s .c o m*/ }; button.setActionCommand("First"); button.addActionListener(actionListener); JOptionPane.showMessageDialog(null, button); }
From source file:Main.java
public static void main(String[] args) { JCheckBox checkBox = new JCheckBox("Enabled", true); checkBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (checkBox.isEnabled()) checkBox.setEnabled(false); else/*from w w w .ja va2 s .c o m*/ checkBox.setEnabled(true); } }); JOptionPane.showMessageDialog(null, checkBox); }
From source file:TimerSample.java
public static void main(String args[]) { Runnable runner = new Runnable() { public void run() { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Hello World Timer"); }//w w w .ja va2 s . c om }; Timer timer = new Timer(500, actionListener); timer.start(); } }; EventQueue.invokeLater(runner); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }/*from w w w . j a va 2s .c o m*/ }); jb.doClick(1000); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }// w w w .j av a 2 s.c om }); jb.doClick(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }/*from ww w . java2s.c o m*/ }); System.out.println(jb.getActionCommand()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }