import java.awt.event.*;
import java.awt.event.ActionListener;

import javax.swing.*;

/**
 * @author Remi Forax
 *
 */
public class DynAddExample {

  public static void main(String[] args) {
    JFrame frame=new JFrame("DynAddExample");
    
    final JPanel panel=new JPanel();
    
    JButton newButton=new JButton("New");
    newButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        JButton button=new JButton("button");
        panel.add(button);
         
        panel.revalidate();
      }
    });
    panel.add(newButton);
    
    frame.setContentPane(panel);
    frame.pack();
    frame.show();
  }
}
