/* * MyFrame.java * * Created on November 3, 2006, 2:30 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package pack; import java.awt.Container; import java.awt.FlowLayout; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class MyFrame extends JFrame implements ActionListener { public MyFrame() { super(); setSize( 350, 400 ); setTitle("My Frame"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel mainPanel = new JPanel(); Container contentPane = getContentPane(); contentPane.add(mainPanel); mainPanel.setLayout(new FlowLayout()); JButton button = new JButton("Press Me"); button.addActionListener(this); mainPanel.add(button); } public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MyFrame().setVisible(true); } }); } public void actionPerformed(ActionEvent e) { System.out.println("Action"); } }