Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. public class Frame extends JFrame
  2. {
  3.     JButton copy;
  4.     JPanel p;
  5.    
  6.     public Frame()
  7.     {
  8.         super("");
  9.         setDefaultCloseOperation(EXIT_ON_CLOSE);
  10.         setSize(500, 500);
  11.  
  12.         p = new JPanel();
  13.        
  14.         copy = new JButton("Copy");
  15.         copy.addActionListener(new ActionListener()
  16.         {
  17.            
  18.             @Override
  19.             public void actionPerformed(ActionEvent arg0)
  20.             {
  21.                 p.add(new JButton("Added"));
  22.                
  23.                 revalidate();
  24.             }
  25.         });
  26.        
  27.         p.add(copy);
  28.        
  29.         add(p);
  30.         setVisible(true);
  31.     }
  32.    
  33.     public static void main(String[] args)
  34.     {
  35.         Frame f = new Frame();
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement