import java.awt.*; import java.awt.event.*; import javax.swing.*; public class GUITestOne extends JFrame{ Container con; JButton button1, button2; public GUITestOne(String winTitle){ super(winTitle); button1 = new JButton("Button 1"); button2 = new JButton("Button 2", new ImageIcon("duke.jpg")); button1.addActionListener(new MyButtonListener1()); button2.addActionListener(new MyButtonListener2()); con = this.getContentPane(); con.setLayout(new FlowLayout()); con.add(button1); con.add(button2); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 500); show(); //this.setVisible(true); } public static void main(String argv[]){ System.out.println("Hello !!!"); new GUITestOne("My Test JFrame"); } } class MyButtonListener1 implements ActionListener{ public void actionPerformed(ActionEvent e){ System.out.println("Checking the Action on button"); } } class MyButtonListener2 implements ActionListener{ public void actionPerformed(ActionEvent e){ new GUITestOne("Action Frame on Button"); } }