Ok, I'm working on a JApplet for my school project. What I want it to do is each time a JButton is clicked, "a menu button", it deletes current content of the container and then adds a new JApplet to the container. I have it sort-of-working, the only error I'm getting is that it's not repainting the contents of the container, but if I adjust the window (I'm using appletviewer to display it currently) it will display what I want it to display. Below is an example of the code I use for my actionPerformed method...
public void actionPerformed(ActionEvent event)
{
if(event.getSource() == word_guess)//JButton
{
WordGuess w = new WordGuess(); //Applet wanted to be displayed
c.remove(main);//removes current content of container
c.remove(side);
c.setLayout(new GridLayout(1,0)); //changes Layout
c.add(w);
w.init(); //calls the init method of WordGuess
repaint(); //I tried to see if repainting would help, and it didn't
}
}