0

so I have a program that first displays a login screen (login_menu()), once the user successfully logs in, then i want to open another screen that allows the user to open an account. My problem now is that both login_menu and my frame are opening at the same time. Is there any way for the second frame to wait for the first one to close?

void open_account() throws FileNotFoundException, IOException {


Account account = new Account();
        Sav_Acct sav_acct = new Sav_Acct();
        Customer customer = new Customer(); // create new customer object

        final JFrame frame = new JFrame("Open Account");
        frame.setSize(500,200);
        JPanel controlPanel = new JPanel();


         login_menu();

         JLabel title = new JLabel("Checkings or Savings?", JLabel.CENTER);
         JButton checkingsbtn = new JButton("Checkings");
         JButton savingsbtn = new JButton("Savings");

         checkingsbtn.setBounds(0, 0, 200, 75);
         savingsbtn.setBounds(250, 0, 200, 75);

         controlPanel.add(title);
         controlPanel.add(checkingsbtn);
         controlPanel.add(savingsbtn);

         frame.add(controlPanel);

         frame.setVisible(true); 
Albert Liu
  • 13
  • 4
  • 1
    Start by having a look at [How to Make Dialogs](http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html) and avoid using `null` layouts, pixel perfect layouts are an illusion within modern ui design. There are too many factors which affect the individual size of components, none of which you can control. Swing was designed to work with layout managers at the core, discarding these will lead to no end of issues and problems that you will spend more and more time trying to rectify – MadProgrammer Nov 04 '15 at 02:56
  • 1
    You mean something like [this suggestion](http://stackoverflow.com/questions/7323086/java-swing-how-can-i-implement-a-login-screen-before-showing-a-jframe)? – Hovercraft Full Of Eels Nov 04 '15 at 02:57
  • Yep, like that suggestion – MadProgrammer Nov 04 '15 at 03:00

0 Answers0