/*
* LoginScreen.java
*
* Created on March 29, 2004, 2:54 PM
*/
package Login;
/**
*
* @author mo
*/
public class LoginScreen extends javax.swing.JFrame {
String username;
int retry = 0;
/** Creates new form LoginScreen */
public LoginScreen() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
getContentPane().setLayout(null);
setTitle("Login Screen");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
getContentPane().add(jTextField1);
jTextField1.setBounds(170, 90, 120, 20);
jLabel1.setText("Login Name:");
getContentPane().add(jLabel1);
jLabel1.setBounds(70, 92, 80, 16);
jLabel2.setText("Password:");
getContentPane().add(jLabel2);
jLabel2.setBounds(70, 122, 90, 16);
getContentPane().add(jTextField2);
jTextField2.setBounds(170, 120, 120, 20);
jLabel3.setText("Attempt:");
getContentPane().add(jLabel3);
jLabel3.setBounds(70, 162, 60, 16);
jLabel4.setText("0/3");
getContentPane().add(jLabel4);
jLabel4.setBounds(140, 162, 80, 16);
jLabel5.setFont(new java.awt.Font("Verdana", 1, 24));
jLabel5.setText("Ossian Travel");
getContentPane().add(jLabel5);
jLabel5.setBounds(90, 20, 190, 40);
jButton1.setText("Login");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(224, 160, 65, 20);
jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
getContentPane().add(jPanel1);
jPanel1.setBounds(60, 70, 240, 130);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(372, 271));
setLocation((screenSize.width-372)/2,(screenSize.height-271)/2);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
username = "" + jTextField1.getText ();
if (username.equals ("123"))
jLabel4.setText("logged in");
else
retry = retry + 1;
jLabel4.setText("0/" + retry);
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new LoginScreen().show();
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel2;
private javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField1;
private javax.swing.JLabel jLabel5;
// End of variables declaration
-----------------------------
if i enter the wrong password it adds 1 to the 'retry' counter correctly. but if im entering the correct password, its not doing anything. not even displaying the text 'logged in'. also im unsure on how to make it only 3 attempts.
do
{
my code
}
while(retry >=3) ???