desparately need help with JDialog

hello.

this is james mcfadden. i am currently developing a video library system. i have a problem logging on to my system. i need to be able to log onto my own system in order to go to either the user main menu or the administrator main menu.

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.border.*;

publicclass HomeEntertainmentextends JPanelimplements ActionListener{

private JTabbedPane jtp =new JTabbedPane();

private JPanel cP1 =new JPanel();

private JPanel cP2 =new JPanel();

private JPanel cP3 =new JPanel();

private JPanel bP1 =new JPanel();

private JPanel bP2 =new JPanel();

private JPanel bP3 =new JPanel();

private JButton jbAdministratorLogOn =new JButton("Log On");

private JButton jbNewUserRegister =new JButton("Register");

private JButton jbExistingUserLogOn =new JButton("Log On");

public HomeEntertainment(){

cP1.setLayout(new BorderLayout());

cP2.setLayout(new BorderLayout());

cP3.setLayout(new BorderLayout());

bP1.setBorder(new TitledBorder("Make a choice"));

bP2.setBorder(new TitledBorder("Make a choice"));

bP3.setBorder(new TitledBorder("Make a choice"));

bP1.add(jbAdministratorLogOn);

bP2.add(jbNewUserRegister);

bP3.add(jbExistingUserLogOn);

cP1.add(bP1, BorderLayout.SOUTH);

cP2.add(bP2, BorderLayout.SOUTH);

cP3.add(bP3, BorderLayout.SOUTH);

jtp.addTab("Administrator", cP1);

jtp.addTab("New User", cP2);

jtp.addTab("Existing User", cP3);

JFrame jf =new JFrame("Home Entertainment");

jf.getContentPane().add(jtp, BorderLayout.CENTER);

jf.setSize(500, 500);

jf.setVisible(true);

jbAdministratorLogOn.addActionListener(this);

jbNewUserRegister.addActionListener(this);

jbExistingUserLogOn.addActionListener(this);

}

publicvoid actionPerformed(ActionEvent e){

if(e.getSource() == jbAdministratorLogOn){

new LogOnInfoDialog().setVisible(true);

}

if(e.getSource() == jbNewUserRegister){

//RegistrationForm r = new RegistrationForm();

//r.setVisible(true);

}

if(e.getSource() == jbExistingUserLogOn){

new LogOnInfoDialog().setVisible(true);

}

}

publicstaticvoid main(String[] args){

new HomeEntertainment();

}

}

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

publicclass LogOn{

LogOnInfoDialog loid =new LogOnInfoDialog();

}

class LogOnInfoDialogextends JDialog{

private JTextField jtfUN =new JTextField(20);

private JPasswordField jtfPW =new JPasswordField(20);

private JButton jbOK =new JButton("OK");

private JButton jbCancel =new JButton("Cancel");

private LogOn logOn =new LogOn();

class LogOn{

String username;

String password;

String[] userUsernameArray =new String[2];

String[] userPasswordArray =new String[2];

String[] adminUsernameArray =new String[1];

String[] adminPasswordArray =new String[1];

}

public LogOnInfoDialog(){

this(null,true);

}

public LogOnInfoDialog(java.awt.Frame parent,boolean child){

userUsernameArray[0] ="Ann Smyth";

userUsernameArray[1] ="John Murphy";

userPasswordArray[0] ="1";

userPasswordArray[1] ="2";

adminUsernameArray[0] ="Administrator";

adminPasswordArray[0] ="0";

super(parent, child);

setTitle("Welcome to Home Entertainment");

JPanel jp1 =new JPanel(new GridLayout(2, 1));

jp1.add(new JLabel("Username"));

jp1.add(new JLabel("Password"));

JPanel jp2 =new JPanel(new GridLayout(2, 1));

jp2.add(jtfUN);

jp2.add(jtfPW);

JPanel jp3 =new JPanel(new BorderLayout(5, 2));

jp3.add(jp1, BorderLayout.WEST);

jp3.add(jp2, BorderLayout.CENTER);

JPanel jp4 =new JPanel();

jp4.add(jbOK);

jp4.add(jbCancel);

getContentPane().add(jp4, BorderLayout.SOUTH);

getContentPane().add(jp3, BorderLayout.CENTER);

jbOK.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

logOn.username = jtfUN.getText().trim();

logOn.password =new String(jtfPW.getPassword());

if(username == userUsernameArray && password == userPasswordArray){

//UserMainMenu umm = new UserMainMenu();

//umm.setVisible(true);

}

if(username == userUsernameArray && password != userPasswordArray || username != userUsernameArray && password == userPasswordArray){

JOptionPane.showMessageDialog(null,"Error\n\nYou have entered an incorrect username and/or password\nPlease try again", null, JOptionPane.ERROR_MESSAGE);

}

if(username == adminUsernameArray && password == adminPasswordArray){

//AdminMainMenu amm = new AdminMainMenu();

//amm.setVisible(true);

}

if(username == adminUsernameArray && password != adminPasswordArray || username != adminUsernameArray && password == adminPasswordArray){

JOptionPane.showMessageDialog(null,"Error\n\nYou have entered an incorrect username and/or password\nPlease try again", null, JOptionPane.ERROR_MESSAGE);

}

setVisible(false);

}

});

jbCancel.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

logOn =null;

setVisible(false);

}

});

}

}

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

publicclass AdminMainMenuextends JFrame{

JPanel pnlBody;

JButton btnAdminProductMenu =new JButton("Product Menu");

JButton btnAdminMemberMenu =new JButton("Member Menu");

JButton btnAdminRentalMenu =new JButton("Rental Menu");

JButton btnAdminMediaMenu =new JButton("Media Menu");

JButton btnAdminLogOff =new JButton("Log Off");

Container contentpane;

public AdminMainMenu(){

super("Main Menu");

contentpane = getContentPane();

contentpane.setLayout(new BorderLayout());

pnlBody =new JPanel();

pnlBody.add(btnAdminProductMenu);

pnlBody.add(btnAdminMemberMenu);

pnlBody.add(btnAdminRentalMenu);

pnlBody.add(btnAdminMediaMenu);

pnlBody.add(btnAdminLogOff);

contentpane.add(pnlBody,BorderLayout.CENTER);

pack();

setVisible(true);

btnAdminProductMenu.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//AdminProductMenu apm = new AdminProductMenu();

//apm.setVisible(true);

}

});

btnAdminMemberMenu.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//AdminMemberMenu amm = new AdminMemberMenu();

//amm.setVisible(true);

}

});

btnAdminRentalMenu.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//AdminRentalMenu arm = new AdminRentalMenu();

//arm.setVisible(true);

}

});

btnAdminMediaMenu.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//AdminMediaMenu amam = new AdminMediaMenu();

//amam.setVisible(true);

}

});

btnAdminLogOff.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

}

});

}

}

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

publicclass UserMainMenuextends JFrame{

JPanel pnlBody;

JButton btnUserProductMenu =new JButton("Product Menu");

JButton btnUserMemberMenu =new JButton("Member Menu");

JButton btnUserRentalMenu =new JButton("Rental Menu");

JButton btnUserMediaMenu =new JButton("Media Menu");

JButton btnUserLogOff =new JButton("Log Off");

Container contentpane;

public UserMainMenu(){

super("Main Menu");

contentpane = getContentPane();

contentpane.setLayout(new BorderLayout());

pnlBody =new JPanel();

pnlBody.add(btnUserProductMenu);

pnlBody.add(btnUserMemberMenu);

pnlBody.add(btnUserRentalMenu);

pnlBody.add(btnUserMediaMenu);

pnlBody.add(btnUserLogOff);

contentpane.add(pnlBody,BorderLayout.CENTER);

pack();

setVisible(true);

btnUserProductMenu.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//UserProductMenu upm = new UserProductMenu();

//upm.setVisible(true);

}

});

btnUserMemberMenu.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//UserMemberMenu umm = new UserMemberMenu();

//umm.setVisible(true);

}

});

btnUserRentalMenu.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//UserRentalMenu urm = new UserRentalMenu();

//urm.setVisible(true);

}

});

btnUserMediaMenu.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//UserMediaMenu umam = new UserMediaMenu();

//umam.setVisible(true);

}

});

btnUserLogOff.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

}

});

}

}

[18883 byte] By [james-mcfaddena] at [2007-11-27 9:33:46]
# 1
> i have a problem logging on to my system. what's the problem?
Michael_Dunna at 2007-7-12 22:56:04 > top of Java-index,Java Essentials,New To Java...
# 2

when i enter the username and password in the login dialog box and press ok, nothing happens. no main menu(s) for user or administrator appear.

i also noticed in the message that i sent you yesterday that i had a few lines in the LogOn.java program that i should not have commented out. here's the correct version of the program. i ran the video library project today again and there was no improvement whatsoever. no main menu(s) for user or administrator appeared at all. whenever i compile the LogOn program as a separate program, 30 errors appear. these are mostly array errors. would you be able to show me how to correct these errors?

thank you very much for your help.

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class LogOn{

LogOnInfoDialog loid = new LogOnInfoDialog();

}

class LogOnInfoDialog extends JDialog{

private JTextField jtfUN = new JTextField(20);

private JPasswordField jtfPW = new JPasswordField(20);

private JButton jbOK = new JButton("OK");

private JButton jbCancel = new JButton("Cancel");

private LogOn logOn = new LogOn();

class LogOn{

String username;

String password;

String[] userUsernameArray = new String[2];

String[] userPasswordArray = new String[2];

String[] adminUsernameArray = new String[1];

String[] adminPasswordArray = new String[1];

}

public LogOnInfoDialog(){

this(null, true);

}

public LogOnInfoDialog(java.awt.Frame parent, boolean child){

super(parent, child);

userUsernameArray[0] = "Ann Smyth";

userUsernameArray[1] = "John Murphy";

userPasswordArray[0] = "1";

userPasswordArray[1] = "2";

adminUsernameArray[0] = "Administrator";

adminPasswordArray[0] = "0";

setTitle("Welcome to Home Entertainment");

JPanel jp1 = new JPanel(new GridLayout(2, 1));

jp1.add(new JLabel("Username"));

jp1.add(new JLabel("Password"));

JPanel jp2 = new JPanel(new GridLayout(2, 1));

jp2.add(jtfUN);

jp2.add(jtfPW);

JPanel jp3 = new JPanel(new BorderLayout(5, 2));

jp3.add(jp1, BorderLayout.WEST);

jp3.add(jp2, BorderLayout.CENTER);

JPanel jp4 = new JPanel();

jp4.add(jbOK);

jp4.add(jbCancel);

getContentPane().add(jp4, BorderLayout.SOUTH);

getContentPane().add(jp3, BorderLayout.CENTER);

jbOK.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

logOn.username = jtfUN.getText().trim();

logOn.password = new String(jtfPW.getPassword());

if(username == userUsernameArray && password == userPasswordArray){

UserMainMenu umm = new UserMainMenu();

umm.setVisible(true);

}

if(username == userUsernameArray && password != userPasswordArray || username != userUsernameArray && password == userPasswordArray){

JOptionPane.showMessageDialog(null, "Error\n\nYou have entered an incorrect username and/or password\nPlease try again", null, JOptionPane.ERROR_MESSAGE);

}

if(username == adminUsernameArray && password == adminPasswordArray){

AdminMainMenu amm = new AdminMainMenu();

amm.setVisible(true);

}

if(username == adminUsernameArray && password != adminPasswordArray || username != adminUsernameArray && password == adminPasswordArray){

JOptionPane.showMessageDialog(null, "Error\n\nYou have entered an incorrect username and/or password\nPlease try again", null, JOptionPane.ERROR_MESSAGE);

}

setVisible(false);

}

});

jbCancel.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

logOn = null;

setVisible(false);

}

});

}

}

james-mcfaddena at 2007-7-12 22:56:04 > top of Java-index,Java Essentials,New To Java...
# 3
I'm having trouble understanding whether you want an inner class here or not?
petes1234a at 2007-7-12 22:56:04 > top of Java-index,Java Essentials,New To Java...