title: JFrame setVisible not working
body: <p>I am building a log in form once the login button is pressed, it closes login frame and should show main menu.</p>
  
  <p>the problem is no matter what I do, it gives me an error cannot find symbol setVisible</p>
  
  <p>Please help me out</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import javax.swing.border.*;
  /**
   *
   * @author 
   */
  public class Login extends Application {
      private JFrame frame;// frame of the interface
      private JLabel name = new JLabel ("Username:");
      private JLabel pass = new JLabel ("Password:");
      private JTextField username = new JTextField();
      private JPasswordField password = new JPasswordField(); // password text box
      private JTextField empty = new JTextField();
      private JButton login = new JButton("Login");
      private JPanel panel = new JPanel();
  
      public Login()
      {
          makeFrame();
      }
      private void makeFrame()
      {
         frame = new JFrame("Login");  
         frame.setSize(300,200);
         makeMenuBar(frame);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container contentPane = frame.getContentPane();
         //makes application start in the center of the screen
         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
         frame.setLocation(d.width/2 - frame.getWidth()/2, d.height/2 - frame.getHeight()/2);
         //border
         UIManager.getDefaults().put("TitledBorder.titleColor", Color.BLACK);
         Border lowerEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
         TitledBorder title = BorderFactory.createTitledBorder(lowerEtched, "Login");
         Font titleFont = UIManager.getFont("TitledBorder.font");
         title.setTitleFont( titleFont.deriveFont(Font.ITALIC + Font.BOLD) );
         panel.setBorder( title );
         //border end
         frame.setVisible(true);  
         frame.add(panel);
  
         panel.add(name);
         panel.add(username);
         panel.add(pass);
         panel.add(password);
         password.setEchoChar('*');
         panel.add(empty);
         empty.setVisible(false);
         panel.add(login);
         login.addActionListener(new ActionListener()
          {public void actionPerformed(ActionEvent e) { try
         {
             String user = username.getText().trim();
             String pass = new String(password.getPassword());
             String sql = "select user,pass from Login where Username = '"+user+"'and pass='"+pass+"'";
  
             if(rs.next())
             {
                 JOptionPane.showMessageDialog(null,"Welcome");
                 frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
  
                 MainScreen s = new MainScreen();
                 s.setVisible(true); //&lt;- here is the problem
             }
             else
             {
                 JOptionPane.showMessageDialog(null,"Wrong username or password");
             }
         }
         catch(Exception ex){
  
         } }
           });
         panel.setLayout(new GridLayout(3,2));
  
      }
  
  }
  </code></pre>