Basically When i click b1 in the Pincode method i want the Balance(); method to run and display a JButton "2" but i want to clear the frame and panel first, so it looks as if its a new frame...
Any help is much appreciated thanks! :)
import java.awt.*;
import javax.swing.*;
import java.text.*;
import java.lang.*;
import java.awt.event.*;
public class Test {
public static JFrame Frame = new JFrame("Test");
public static void Pincode() {
Frame.setSize(1440,900);
Frame.setVisible(true);
Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setLayout(null);
Frame.add(panel);
JButton b1 = new JButton("1");
b1.setBounds(570,300,100,100);
panel.add(b1);
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
Balance();
}
});
}
public static void Balance() {
Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setLayout(null);
Frame.add(panel);
JButton b2 = new JButton("2");
b2.setBounds(570,300,100,100);
panel.add(b2);
}
public static void main(String [] args){
Pincode();
}
}