problem trying to get the program for my logon screen working
hello.
i have developed a simple logon program. when i try to compile the program, i get 5 errors (errors + code are shown below). what in god's name are causing these errors and how can they be fixed?
thank you for your generous assistance.
-jGRASP exec: javac -g E:\CP4B Project\LogOn.java
LogOn.java:50: cannot find symbol
symbol: variable logOn
logOn = null;
^
LogOn.java:72: cannot find symbol
symbol : method setVisible(boolean)
location: class User
setVisible(false);
^
LogOn.java:83: cannot find symbol
symbol : method setVisible(boolean)
location: class User
setVisible(false);
^
LogOn.java:109: cannot find symbol
symbol : method setVisible(boolean)
location: class Administrator
setVisible(false);
^
LogOn.java:120: cannot find symbol
symbol : method setVisible(boolean)
location: class Administrator
setVisible(false);
^
5 errors
-jGRASP wedge2: exit code for process is 1.
-jGRASP: operation complete.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
publicclass LogOnextends JFrame{
JTextField jtfUN =new JTextField(20);
JPasswordField jtfPW =new JPasswordField(20);
JButton jbOK =new JButton("OK");
JButton jbCancel =new JButton("Cancel");
public LogOn(){
super("Welcome to Home Entertainment");
setSize(250, 250);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel jp =new JPanel();
JLabel unLabel =new JLabel("Username: ");
JLabel pwLabel =new JLabel("Password: ");
jp.add(unLabel);
jp.add(jtfUN);
jp.add(pwLabel);
jp.add(jtfPW);
jp.add(jbOK);
jp.add(jbCancel);
setContentPane(jp);
pack();
jbOK.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
User u =new User();
u.doLogOn();
u.username = jtfUN.getText().trim();
u.password =new String(jtfPW.getPassword());
Administrator a =new Administrator();
a.doLogOn();
a.username = jtfUN.getText().trim();
a.password =new String(jtfPW.getPassword());
}
});
jbCancel.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
logOn =null;
setVisible(false);
}
});
}
publicstaticvoid main(String[] args){
LogOn logOn =new LogOn();
}
}
class User{
String username;
String password;
String[] userUsernameArray ={"Ann Smyth","John Murphy"};
String[] userPasswordArray ={"1","2"};
publicvoid doLogOn(){
int i, j;
for(i = 0; i < userUsernameArray.length; i++){
if(username.equals(userUsernameArray[i])){
setVisible(false);
//UserMainMenu umm = new UserMainMenu();
//umm.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"Error\n\nYou have entered an incorrect username and/or password\nPlease try again", null, JOptionPane.ERROR_MESSAGE);
}
}
for(j = 0; j < userPasswordArray.length; j++){
if(password.equals(userPasswordArray[j])){
setVisible(false);
//UserMainMenu umm = new UserMainMenu();
//umm.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"Error\n\nYou have entered an incorrect username and/or password\nPlease try again", null, JOptionPane.ERROR_MESSAGE);
}
}
}
}
class Administrator{
String username;
String password;
String[] adminUsernameArray ={"Administrator"};
String[] adminPasswordArray ={"0"};
publicvoid doLogOn(){
int k, l;
String username;
String password;
String[] adminUsernameArray ={"Administrator"};
String[] adminPasswordArray ={"0"};
for(k = 0; k < adminUsernameArray.length; k++){
if(username.equals(adminUsernameArray[k])){
setVisible(false);
//AdminMainMenu amm = new AdminMainMenu();
//amm.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"Error\n\nYou have entered an incorrect username and/or password\nPlease try again", null, JOptionPane.ERROR_MESSAGE);
}
}
for(l = 0; l < adminPasswordArray.length; l++){
if(password.equals(adminPasswordArray[l])){
setVisible(false);
//AdminMainMenu amm = new AdminMainMenu();
//amm.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"Error\n\nYou have entered an incorrect username and/or password\nPlease try again", null, JOptionPane.ERROR_MESSAGE);
}
}
}
}

