User selects either the Admin radio button or the User radio button (2 of which are contained in a group). If admin radio button is selected the user is brought to the adminDashboard, else the user is brought to the userDashboard.
I have been looking for code to validate which radio button is selected although I can't find any correct java code
my current button and listener method code (trying to use isSelected())
JButton btnEnter = new JButton("Enter");
btnEnter.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
if(rdbtnAdminAccount.isSelected())
{
AdminDashboard admin = new AdminDashboard();
}
else if (rdbtnNormalAccount.isSelected())
{
UserDashboard userd = new UserDashboard();
}
}
});
radio button and group code:
JRadioButton rdbtnNormalAccount = new JRadioButton("Normal Account");
rdbtnNormalAccount.setBounds(361, 190, 109, 23);
contentPane.add(rdbtnNormalAccount);
JRadioButton rdbtnAdminAccount = new JRadioButton("Admin Account");
rdbtnAdminAccount.setBounds(361, 213, 109, 23);
contentPane.add(rdbtnAdminAccount);
accountGroup.add(rdbtnNormalAccount);
accountGroup.add(rdbtnAdminAccount);