Adding Components to Container

admin

Administrator
Staff member
I am trying to add new components (in this case new buttons) to acontainer (in this case a panel) after the container is already beingdisplayed on the screen. Unfortunately, these new buttons do not appearuntil the window is resized. I'm not sure, but I don't think that thisis a repaint problem. Does anyone know how to add new components to thedisplay? Any input would be appreciated.------------------------------------------import java.applet.*;import java.awt.*;import java.awt.event.*;public class test extends Applet{Panel p = new Panel();public void init() {p.setLayout(new FlowLayout());Button b = new Button("ADD");p.add(b);add(p);b.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){p.add(new Button ("I'm Here"));}});}}
 
Back
Top