import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Window.Type;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class WelcomePage extends AdminLogin {
private JFrame frame;
private JButton btnAdmin;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
WelcomePage window = new WelcomePage();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public WelcomePage() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(Color.BLUE);
frame.setBackground(Color.BLUE);
frame.setBounds(100, 100, 495, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel lblOnlineElectionManager = new JLabel(
"Welcome To Online Election Manager");
lblOnlineElectionManager.setForeground(Color.WHITE);
lblOnlineElectionManager.setFont(new Font("Tahoma", Font.PLAIN, 16));
lblOnlineElectionManager.setBounds(100, 11, 284, 47);
frame.getContentPane().add(lblOnlineElectionManager);
JLabel lblLoginAs = new JLabel("Login as");
lblLoginAs.setForeground(Color.WHITE);
lblLoginAs.setFont(new Font("Tahoma", Font.PLAIN, 16));
lblLoginAs.setBounds(195, 84, 77, 36);
frame.getContentPane().add(lblLoginAs);
btnAdmin = new JButton("ADMIN");
btnAdmin.setFont(new Font("Tahoma", Font.PLAIN, 16));
btnAdmin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnAdmin) {
AdminLogin admin = new AdminLogin();
frame.setVisible(false);
admin.setVisible(true);
}
}
});
btnAdmin.setBounds(45, 192, 117, 36);
frame.getContentPane().add(btnAdmin);
JButton btnVoter = new JButton("VOTER");
btnVoter.setFont(new Font("Tahoma", Font.PLAIN, 16));
btnVoter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
btnVoter.setBounds(267, 192, 117, 36);
frame.getContentPane().add(btnVoter);
}
}
What I have tried:
I tried creating an instance of the second class "AdminLogin" which i want to move to after clicking a button on this "WelcomePage" class. When i try to run there's an error at "admin.setVisible(true)". What did i do wring?