title: how to pass a variable from one JFrame to another
body: <p>I have two <code>JFrames</code> <strong>newAccessLevels.java</strong>, which has two buttons "Level 1" "Level 2" and <strong>newAccessPanel.java</strong> 
  I need to get the level that the user selects "1 or 2" onto the <code>accessPanel</code> so I can display it in the title of the <strong>accessPanel.java</strong> e.g. Access Level 1, Access Level 2. How can this be done. below is example code, so if level 1 is clicked the newAccessPanel JFrame will open with the title *<em>ACCESS LEVEL 1</em> and vice versa for level 2:</p>
  
  <p><strong>newAccessLevels.java</strong></p>
  
  <pre><code>package securitySystem;
  
  import java.awt.*;
  import javax.swing.*;
  import java.sql.*;
  import java.awt.event.*;
  
  public class newAccessLevels extends JFrame{
  
  public static void main (String args[]){
      newAccessLevels gui= new newAccessLevels ();
      gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      gui.setTitle("Access Levels");
      gui.setSize(400,400);
      gui.setLocationRelativeTo(null);
      gui.setVisible(true);       
  }
  
  JButton btnLevel1= new JButton("Levels 1");
  JButton btnLevel2= new JButton("Level 2");
  
  
  public newAccessLevels (){
      setLayout (null);
  
      btnLevel1.setBounds(120,70, 150, 30);
      add(btnLevel1);
  
      btnLevel2.setBounds(120,130, 150, 30);
      add(btnLevel2); 
  }
  
  public void calcButtons()
  {
      btnLevel1.addActionListener(new ActionListener()
      {
          public void actionPerformed(ActionEvent e) 
          {
              newAccessPanel gui =new newAccessPanel();
              gui.setSize (360, 450);
              gui.setLocationRelativeTo(null);
              gui.setVisible(true);
              dispose();              
          }
      });
  
      btnLevel2.addActionListener(new ActionListener()
      {
          public void actionPerformed(ActionEvent e) 
          {
              newAccessPanel gui =new newAccessPanel();
              gui.setSize (360, 450);
              gui.setLocationRelativeTo(null);
              gui.setVisible(true);
              dispose();              
          }
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>newAccessPanel.java</strong> </p>
  
  <pre><code>package securitySystem;
  
  import java.awt.*;
  import javax.swing.*;
  import java.sql.*;
  import java.awt.event.*;
  
  public class newAccessPanel extends JFrame{
  
  public static void main (String args[]){
      newAccessPanel gui= new newAccessPanel ();
      gui.setSize (360, 450);
      gui.setLocationRelativeTo(null);
      gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      gui.setVisible(true);
      gui.setTitle("ACCESS LEVEL '1/2'");     
      //gui.setLayout(new BorderLayout());
      //gui.setBackground(Color.BLACK);       
  }
  </code></pre>
  
  <p>}</p>