title: Java Store Register Application Navigational Mechanics
body: <p>I am trying to make a Store Register application in Java (for fun), but I am new to the language and am not exactly sure how to proceed from where I am. Currently, I successfully created a login system so when I hit login, the user login works. Now, I want to make it so that when I click login, it takes me to a menu of options. I do NOT want to open a new JFrame when the user clicks login, but instead, I want everything to happen in one a single JFrame. Also, I do not want you guys to do it for me, but i want to know how to approach this. </p>
  
  <p>Here is the code I have for reference:</p>
  
  <pre><code>package schoolstoreregister;
  
  
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  public class SchoolStoreRegister extends JFrame {
  
          //declaring our swing components
      JLabel l_name,l_pass;
      JTextField t_name;
      JPasswordField t_pass;     //A special JTextField but hides input text
      JButton button;
      Container c;
      boolean checkLogin = false;
  
      //a inner class to handling ActionEvents
      handler handle;
  
      //a separate class for processing database connection and authentication
      database db;    
  
      SchoolStoreRegister()
      {
          super("School Store Register");
  
          c=getContentPane();
          c.setLayout(new FlowLayout());
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          int width = (int) screenSize.getWidth();
          int height = (int) screenSize.getHeight();
  
          //extra classes
          db=new database();
              handle =new handler();
  
                  //swing components
          //l_name=new JLabel("Username");
          l_pass=new JLabel("Password");
          //t_name=new JTextField(10);
          t_pass=new JPasswordField(10);
          button=new JButton("Login");
  
          //adding actionlistener to the button
          button.addActionListener(handle);
  
          //add to contaienr
         // c.add(l_name);
          //c.add(t_name);
          c.add(l_pass);
          c.add(t_pass);
          c.add(button);
          //visual
          setVisible(true);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setSize(width,height);
  
      }
      public static void main(String args[])
      {
              @SuppressWarnings("unused")
              SchoolStoreRegister sample=new SchoolStoreRegister();
      }
  
      class handler implements ActionListener        //This is triggered whenever the user clicks the login button
      {
          public void actionPerformed(ActionEvent ae) //checks if the button clicked
          {
              if(ae.getSource()==button)
              {
                  char[] temp_pwd=t_pass.getPassword();
                  String convert = t_pass.getText();
                  int passID = Integer.parseInt(convert);
  
                  //The entered username and password are sent via "checkLogin()" which return boolean
                  if(db.checkLogin(passID))
                  {
                      //a pop-up box
                      JOptionPane.showMessageDialog(null, "You have logged in successfully","Success", JOptionPane.INFORMATION_MESSAGE);
                      checkLogin = true;
                  }
                  else
                  {
                      //a pop-up box
                      JOptionPane.showMessageDialog(null, "Login failed!","Failed!!", JOptionPane.ERROR_MESSAGE);
                      checkLogin = false;
                  }
              }//if
          }//method
  
      }//inner class
  }
  </code></pre>