views:

25

answers:

2

hi i am new to Java i developed many forms but i am unable to connect those forms please any one tell me how can connect one form to another form for example after login screen my application form should be open

+1  A: 

I hope you are asking about swing ,

loginFrame.setVisible(false);
new ApplicationWelComePage.setVisible(true);
org.life.java
A: 

It sounds like you're coming from a Visual Basic background and you are trying to have some kind of procedure to display a login window, then a main program window.

There are many different ways to do this, but the two most common would be:

Display login dialog
Retrieve login information from closed dialog
Validate or exit/redisplay login
Display main window

and

Display login window
On 'OK' being pressed, validate or exit/display error
Hide self
Show main window

The first would be implemented something like this:

public static void main(String[] args) {
    LoginDialog dlg = new LoginDialog();
    dlg.setVisible(true);
    LoginCredentials cred = dlg.getCredentials();
    if ( ! valid(cred)) {
        System.exit(1);
    }
    MainWindow wnd = new MainWindow(cred);
    wnd.setVisible(true);
}

The second would look more like this:

public static void main(String[] args) {
    LoginWindow app = new LoginWindow();
    app.setVisible(true);
}

LoginWindow.actionPerformed(ActionEvent e) {
    if ( ! validCredentials()) {
        System.exit(1);
    }
    setVisible(false);
    dispose();
    MainWindow wnd = new MainWindow();
    wnd.setVisible(true);
}

I recommend the first, so you can reuse the LoginDialog in other places, as it does not start the main window of this specific application itself.

Jonathan