-
java Swing Interface
I am coding my project in Swing and have a set of .java files with all the various interface screens i.e. main menu etc using JFrames.
I need to link these together i.e. Press a button on the Main menu screen which then goes to the password screen etc.
I have an idea that i need to put a call to the class I want to dispay in the actionperformed method of the class I am using but although the code passwordscreen.show(); compiples it does nothing!
What am I missing out?
-
Re: java Swing Interface
For the Login Button on the Main Menu Add a ActionListener( Class which implements ActionListener
Interface) by calling addActionListener method of the button. Then in the
actionPerformed method of the ActionListener Class add the code passwordscreen.show(), better would be
passwordscreen.setVisible(true)
E.g
Button loginBtn = new Button("Login");
.....
.....
loginBtn.addActionListener(new LoginHandler());
.....
class LoginHandler implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
passwordscreen.setVisible(true);
}
}
Note: To handle events the above way, you should using java 1.1 and not java 1.0