3. called.");
String username = new String(jTextField1.getText());
String password = new String(jPasswordField1.getText());
if(username.equals("") || password.equals("")) // If password and
username is empty > Do this >>>
{
jButton1.setEnabled(false);
JLabel errorFields = new JLabel("<HTML><FONT COLOR =
Blue>You must enter a username and password to login.</FONT></HTML>");
JOptionPane.showMessageDialog(null,errorFields);
jTextField1.setText("");
jPasswordField1.setText("");
jButton1.setEnabled(true);
this.setVisible(true);
}
else
{
JLabel optionLabel = new JLabel("<HTML><FONT COLOR = Blue>You
entered</FONT><FONT COLOR = RED> <B>"+username+"</B></FONT> <FONT COLOR =
Blue>as your username.<BR> Is this correct?</FONT></HTML>");
int confirm =JOptionPane.showConfirmDialog(null,optionLabel);
switch(confirm){ // Switch > Case
case JOptionPane.YES_OPTION: // Attempt to Login user
jButton1.setEnabled(false); // Set button enable to false to
prevent 2 login attempts
break;
case JOptionPane.NO_OPTION: // No Case.(Go back. Set text to
0)
jButton1.setEnabled(false);
jTextField1.setText("");
jPasswordField1.setText("");
jButton1.setEnabled(true);
break;
case JOptionPane.CANCEL_OPTION: // Cancel Case.(Go back. Set
text to 0)
jButton1.setEnabled(false);
jTextField1.setText("");
jPasswordField1.setText("");
jButton1.setEnabled(true);
break;
} // End Switch > Case
}
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{