I have java database application.
I have login form using JDialogForm and I have Main program. The problem is I want to call JDialogForm when I run my main program and if the DialogForm is closed, I want my main program Appear.

I have try it, but failed..... can you help me please....??

Recommended Answers

All 2 Replies

I have java database application.
I have login form using JDialogForm and I have Main program. The problem is I want to call JDialogForm when I run my main program and if the DialogForm is closed, I want my main program Appear.

I have try it, but failed..... can you help me please....??

Hi aktor

what you have to do is to either make the main frame invisible when starting up and the JDialogForm to invoke the MainForm and make it visible if the login details provided are correct. If you dont understand just paste the code here and I can help you from it.

Regards

Kylex

I recommend to leave out the whole idea of JDialogForm as login option. Create frame just for collecting login details and once user provide correct data just call main application. Something like this

public class MyGUI
{

    public static void main(String args[])
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                LoginFrame lf = new LoginFrame();
                lf.runLoginFrame(); // Calling Login Frame
            }
        });
    }
}

Snipped of LoginFrame

public class LoginFrame extends JFrame
{
    public LoginFrame()
    {
        super();
    }

    public void runLoginFrame()
    {
        setTitle("Login Fra,e");
        LoginPanel loginJP = new LoginPanel();

        setSize(dimLF);
        getContentPane().add(loginJP);

        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocation(rp.resultPosition(dimLF));
        setResizable(false);
        setVisible(true);
    }
    /* MORE CODE HERE*/

    /*After validation and comparing with database record re-direct to next frame*/
    MainGUI mgui = new MainGUI();
    mgui.runMainGUI();
}

Bellow method uses simple validation if collected data full fit certain criteria (min & max character count, exclusion of special characters etc.) plus compare agains

public class MainGUI extends JFrame{
    
    public MainGUI(){}

    public void runMainGUI()
    {
        Dimension d = new Dimension(500, 550);
        setTitle("Main GUI");
        setSize(d);
        setLocation(rp.resultPosition(d));
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setMenuBar();
        setJMenuBar(jmb);
        getContentPane().add(mainPanel);
        setResizable(false);
        setVisible(true);
    }

    /* MORE CODE HERE*/
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.