S
sent1729
Hi all,
I my app. I have a JDialog with a Textfield , based on the text I
enter, I want to open up a new frame (just like using a password)
This is what I did for testing:
public static JTextField jtxtUserName = new JTextField();
public static JButton button = new JButton();
public NewClass(Frame owner, boolean modal){
super(owner,modal);
Container cp = getContentPane();
button.setText("Initialize");
cp.add(jtxtUserName);
jtxtUserName.setBounds(100,10,200,20);
button.setBounds(200,85,100,22);
button.addActionListener( this );
}
public void actionPerformed(ActionEvent e) {
if( e.getSource() == button )
{
if (jtxtPassword.getText().toString() == "ABCD"){
System.exit(0);
}
}
My problem is, when I run my app. and type "ABCD" for the user name and
hit the "start"button , i expect the app. to close. but it does not. if
I print out jtxtPassword.getText().toString() it shows ABCD, but the
programme does not get in to the if statement ( if
(jtxtPassword.getText().toString() == "ABCD") ).
AM I doing something wrong?
Any input will be greatly appreciated.
Thanks
Nathan.
I my app. I have a JDialog with a Textfield , based on the text I
enter, I want to open up a new frame (just like using a password)
This is what I did for testing:
public static JTextField jtxtUserName = new JTextField();
public static JButton button = new JButton();
public NewClass(Frame owner, boolean modal){
super(owner,modal);
Container cp = getContentPane();
button.setText("Initialize");
cp.add(jtxtUserName);
jtxtUserName.setBounds(100,10,200,20);
button.setBounds(200,85,100,22);
button.addActionListener( this );
}
public void actionPerformed(ActionEvent e) {
if( e.getSource() == button )
{
if (jtxtPassword.getText().toString() == "ABCD"){
System.exit(0);
}
}
My problem is, when I run my app. and type "ABCD" for the user name and
hit the "start"button , i expect the app. to close. but it does not. if
I print out jtxtPassword.getText().toString() it shows ABCD, but the
programme does not get in to the if statement ( if
(jtxtPassword.getText().toString() == "ABCD") ).
AM I doing something wrong?
Any input will be greatly appreciated.
Thanks
Nathan.