So, I'm creating a sort menu and I have a Log on screen.When the user logs on it loads another menu. I have it load the second menu but i don't know how to wipe the log in button and the textfields etc. how would i go about doing this?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame{
public void fixtureList() //Here is where all of the fixture/timetable elements are based.
{
JButton editButton;
JButton createButton;
JButton logoutButton;
editButton = new JButton("Edit");
editButton.setBounds(10, 10, 80, 30);
add(editButton);
createButton = new JButton(("Create"));
createButton.setBounds(145, 10, 80, 30);
add(createButton);
logoutButton = new JButton(("Log Out"));
logoutButton.setBounds(10, 350, 80, 30);
add(logoutButton);
logoutButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//Execute when button is pressed
loginPanel();
System.out.println("Loading the login screen");
repaint();
}
});
}
public void loginPanel() //This is where the screen containing all of the login elements is based.
{
setLayout(null);
JButton loginButton;
JTextField usernameField;
JPasswordField passwordField;
loginButton = new JButton("Login");
loginButton.setBounds(80, 250, 70, 30);
add(loginButton);
usernameField = new JTextField(15);
usernameField.setBounds(60, 110, 130, 30);
add(usernameField);
passwordField = new JPasswordField(15);
passwordField.setBounds(60, 150, 130, 30);
add(passwordField);
loginButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//Execute when button is pressed
fixtureList();
System.out.println("Loading the fixtures screen");
repaint();
}
});
}
public static void main(String[] args)
{
Main window = new Main();
window.setTitle("PE Fixtures v1.0");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(250, 430);
window.loginPanel();
window.setResizable(false);
window.getContentPane().setBackground(new Color(53, 56, 64));
window.setVisible(true);
}
}
});