SimpleButton3 using Eclipse IDE

Main.java  [download]

import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class Main extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Main frame = new Main(); //*1 Slightly different scheme for window setup
					frame.setVisible(true); //*1
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Main() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 300, 300); 
		contentPane = new JPanel();
		setContentPane(contentPane);
		contentPane.setLayout(new FlowLayout());
		
		JButton btnNewButton = new JButton("Push me"); //*2 By default, puts all the widgets in main program
		btnNewButton.addActionListener(new ActionListener() { //*3 Anonymous inner class as listener
			public void actionPerformed(ActionEvent e) { //*3
				System.out.println ("Button was pushed"); //*3
			}
		});
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("Push me also"); //*2
		btnNewButton_1.addActionListener(new ActionListener() { //*3
			public void actionPerformed(ActionEvent e) { //*3
				System.out.println ("Button was pushed"); //*3
			}
		});
		contentPane.add(btnNewButton_1);
	}
}