Bapa

Untitled

Mar 17th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3.  
  4. public class ActionTest extends Frame
  5. {
  6.                  public ActionTest()
  7.   {
  8.   Button test=new Button("Test");
  9.   add(test);
  10.   test.addActionListener(new ActionListener()
  11.   {
  12.   public void actionPerformed(ActionEvent e)
  13.   {
  14.   System.out.println("Clicked");
  15.   Button b=(Button)e.getSource();
  16.   b.addActionListener(new ActionListener()
  17.   {
  18.   public void actionPerformed(ActionEvent e)
  19.   {
  20.   System.out.println("Clicked again");
  21.   }
  22.   });
  23.   }
  24.   });
  25.  
  26.                                 setSize(100,100);
  27.     setVisible(true);
  28.                                 setTitle("My Frame");
  29.       }
  30.  
  31.   public static void main(String rgs[])
  32.   {
  33.                               new ActionTest();
  34.   }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment