how do i reset the applet?
i thought that it would work if i call the method itself
thanks
private class ButtonListener1 implements ActionListener{
public void actionPerformed(ActionEvent e){
myButton1.setBackground(Color.black);
int answer = JOptionPane.YES_OPTION;
answer = JOptionPane.showConfirmDialog(null,
"BOOOoooM!!! Would you like to play again?", "", JOptionPane.YES_NO_OPTION);
if(answer == JOptionPane.YES_OPTION){
LoanApplet reset = new LoanApplet();
reset.reset();
}
else{
//p1.setVisible(false);
}
}
}
public void reset(){
JPanel p1 = new JPanel(new GridLayout(3, 3));
int randomNumber = (int)(Math.random()*9)+1;
if(randomNumber == 1){
p1.add(myButton1);
p1.add(myButton2);
p1.add(myButton3);
p1.add(myButton4);
p1.add(myButton5);
p1.add(myButton6);
p1.add(myButton7);
p1.add(myButton8);
p1.add(myButton9);
}
if(randomNumber == 2){
p1.add(myButton2);
p1.add(myButton1);
p1.add(myButton3);
p1.add(myButton4);
p1.add(myButton5);
p1.add(myButton6);
p1.add(myButton7);
p1.add(myButton8);
p1.add(myButton9);
}
add(p1, BorderLayout.CENTER);
myButton1.addActionListener(new ButtonListener1());
myButton2.addActionListener(new ButtonListener2());
}