Advertisement
Guest User

Untitled

a guest
Sep 18th, 2012
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.awt.FlowLayout;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4.  
  5. import javax.swing.JButton;
  6. import javax.swing.JFrame;
  7.  
  8.  
  9. public class SimpleWindow extends JFrame {
  10.  
  11.     public SimpleWindow() {
  12.         super ("A window");
  13.         JButton b = new JButton("Click");
  14.         b.addActionListener( new ActionListener(){
  15.  
  16.             @Override
  17.             public void actionPerformed(ActionEvent e) {
  18.                 new SimpleWindow();
  19.                
  20.             }
  21.            
  22.         });
  23.         setLayout(new FlowLayout());   
  24.         getContentPane().add(b);
  25.         setSize(200, 200);
  26.         setVisible(true);
  27.     }
  28.    
  29.     public static void main(String[] args) {
  30.         new SimpleWindow();
  31.  
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement