Writing a small Swing Applet,
Has two panels, one at the bottom with a 'back' and 'next' button and a main panel above the bottom panel which has various checkboxes on it for the user to input the answer to questions.
What I want is when the next button is pressed all the checkboxes dissapear and a new question is asked and new checkboxes drawn.
So basically I want the applet to cycle through 10 or so questions to the user then display results on a final page.
I thought the way to do it would be to create 10 different panels (panes?) with all the controls added to them, then remove the previous / add next panel when the button is clicked.
Problem is when the button is clicked it will not remove the previous panel:
public void actionPerformed(ActionEvent e)
{
getContentPane().remove(mainPanel);
}
If I put the 'getContentPane().remove(mainPanel);' line under the 'public void init()' of the applet it works fine, I just can't get it to remove a panel when a button is clicked. Do I need the update() function, if so what argument does it take, I can't figure it out.
Many thanks
Dom.
Has two panels, one at the bottom with a 'back' and 'next' button and a main panel above the bottom panel which has various checkboxes on it for the user to input the answer to questions.
What I want is when the next button is pressed all the checkboxes dissapear and a new question is asked and new checkboxes drawn.
So basically I want the applet to cycle through 10 or so questions to the user then display results on a final page.
I thought the way to do it would be to create 10 different panels (panes?) with all the controls added to them, then remove the previous / add next panel when the button is clicked.
Problem is when the button is clicked it will not remove the previous panel:
public void actionPerformed(ActionEvent e)
{
getContentPane().remove(mainPanel);
}
If I put the 'getContentPane().remove(mainPanel);' line under the 'public void init()' of the applet it works fine, I just can't get it to remove a panel when a button is clicked. Do I need the update() function, if so what argument does it take, I can't figure it out.
Many thanks
Dom.