title: How can a Global Variable be recognize in two different window (Java Swing GUI)
body: <p>I've just started Studying Java GUI on Eclipse
  Well I've challenged myself to create an Address Book</p>
  
  <p>So here what I Got</p>
  
  <p>FRONT (Swing Application Window)</p>
  
  <pre><code>package byDavid;
  
  import java.awt.EventQueue;
  
  import javax.swing.JFrame;
  import javax.swing.JTextArea;
  import java.awt.BorderLayout;
  import javax.swing.JTextField;
  import java.awt.Color;
  import javax.swing.JPanel;
  import javax.swing.DropMode;
  import java.awt.Toolkit;
  import javax.swing.JList;
  import javax.swing.JMenuBar;
  import javax.swing.JLabel;
  import java.awt.Font;
  import javax.swing.JButton;
  import javax.swing.ButtonGroup;
  import java.awt.event.ActionListener;
  import java.awt.event.ActionEvent;
  import javax.swing.JScrollPane;
  
  public class Front {
  
  private JFrame frame;
  private final ButtonGroup buttonGroup = new ButtonGroup();
  protected int top = 0;               //Define Top for Stack Implementation
  private static final int MAXENTRIES = 100;   //Define Array Size
  
  /**
   * Launch the application.
   */
  public static void main(String[] args) {
  
   final AdressBookEntry[]list;  //List is declared here 
  
  
      EventQueue.invokeLater(new Runnable() {
          public void run() {
              try {
                  Front window = new Front();
                  window.frame.setVisible(true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      });
  }
  
  /**
   * Create the application.
   */
  public Front() {
      initialize();
  }
  
  /**
   * Initialize the contents of the frame.
   */
  private void initialize() {
      frame = new JFrame();
      frame.setIconImage(Toolkit.getDefaultToolkit().getImage(Front.class.getResource("/com/sun/javafx/webkit/prism/resources/missingImage.png")));
      frame.setBounds(100, 100, 357, 300);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().setLayout(null);
  
      JList list = new JList();
      JScrollPane scroll = new JScrollPane(list);
      scroll.setBounds(24, 22, 185, 210);
      frame.getContentPane().add(scroll);
  
      JLabel lblNameEntrees = new JLabel("Name of Entrees");
      lblNameEntrees.setBounds(50, 0, 134, 21);
      frame.getContentPane().add(lblNameEntrees);
      lblNameEntrees.setFont(new Font("Cambria Math", Font.BOLD, 17));
  
      JButton btnAddNewEntry = new JButton("Add Entry\r\n");
      btnAddNewEntry.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
  
              AddEntry nw = new AddEntry();
              nw.Addentry();
          }
      });
      buttonGroup.add(btnAddNewEntry);
      btnAddNewEntry.setBounds(231, 40, 100, 23);
      frame.getContentPane().add(btnAddNewEntry);
  
      JButton btnUpdateEntry = new JButton("Update Entry");
      buttonGroup.add(btnUpdateEntry);
      btnUpdateEntry.setBounds(231, 74, 99, 23);
      frame.getContentPane().add(btnUpdateEntry);
  
      JButton btnNewButton = new JButton("Delete Entry");
      buttonGroup.add(btnNewButton);
      btnNewButton.setBounds(231, 108, 100, 23);
      frame.getContentPane().add(btnNewButton);
  
      JButton btnNewButton_1 = new JButton("Quit");
      btnNewButton_1.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
          frame.dispose();
          }
      });
      buttonGroup.add(btnNewButton_1);
      btnNewButton_1.setBounds(231, 140, 100, 23);
      frame.getContentPane().add(btnNewButton_1);
  
      JMenuBar menuBar = new JMenuBar();
      frame.setJMenuBar(menuBar);
  }
  }
  </code></pre>
  
  <p>AddEntry (Swing Application Window) /Another A pop-Up Window</p>
  
  <pre><code>package byDavid;
  
  import java.awt.EventQueue;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import java.awt.BorderLayout;
  import javax.swing.JTextField;
  import java.awt.Window.Type;
  import org.eclipse.wb.swing.FocusTraversalOnArray;
  import java.awt.Component;
  import javax.swing.JButton;
  import java.awt.event.ActionListener;
  import java.awt.event.ActionEvent;
  
  public class AddEntry {
  
  
  private JFrame frame;
  private JTextField textField;
  private JTextField textField_1;
  private JTextField textField_2;
  private JTextField textField_3;
  private JButton btnQuit;
  private JButton btnAccept;
  
  /**
   * Launch the application.
   */
  public static void Addentry() {
      EventQueue.invokeLater(new Runnable() {
          public void run() {
              try {
                  AddEntry window = new AddEntry();
                  window.frame.setVisible(true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      });
  }
  
  /**
   * Create the application.
   */
  public AddEntry() {
      initialize();
  }
  
  /**
   * Initialize the contents of the frame.
   */
  private void initialize() {
  
  
      JTextField name  ;
      JTextField add ;
      JTextField tel ;
      JTextField email;
  
      String name1 = "";
      String add1 ="";
      long tel1 = 0;
      String email1 = "";
  
  
      frame = new JFrame();
      frame.setType(Type.POPUP);
      frame.setBounds(100, 100, 369, 219);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().setLayout(null);
  
      JLabel lblName = new JLabel("Name:");
      lblName.setBounds(10, 11, 62, 32);
      frame.getContentPane().add(lblName);
  
      JLabel lblAdress = new JLabel("Adress:");
      lblAdress.setBounds(10, 42, 62, 32);
      frame.getContentPane().add(lblAdress);
  
      JLabel lblPhoneNumber = new JLabel("Phone Number:");
      lblPhoneNumber.setBounds(10, 77, 99, 32);
      frame.getContentPane().add(lblPhoneNumber);
  
      JLabel lblEmailAddress = new JLabel("Email Address:");
      lblEmailAddress.setBounds(10, 108, 99, 32);
      frame.getContentPane().add(lblEmailAddress);
  
      name = new JTextField();
      name.setBounds(119, 15, 207, 25);
      frame.getContentPane().add(name);
      name.setColumns(10);
  
      add = new JTextField();
      add.setColumns(10);
      add.setBounds(118, 46, 208, 25);
      frame.getContentPane().add(add);
  
      tel = new JTextField();
      tel.setColumns(10);
      tel.setBounds(119, 81, 207, 25);
      frame.getContentPane().add(tel);
  
      email = new JTextField();
      email.setColumns(10);
      email.setBounds(119, 112, 207, 25);
      frame.getContentPane().add(email);
  
      btnQuit = new JButton("Close");
      btnQuit.addActionListener(new ActionListener() {
  
          public void actionPerformed(ActionEvent e) {
          frame.dispose();
          }
      });
  
      btnQuit.setBounds(237, 148, 89, 23);
      frame.getContentPane().add(btnQuit);
  
      btnAccept = new JButton("Accept");
      btnAccept.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
  
              name.getText();
              add.getText();
              tel.getText();
              email.getText();
              frame.dispose();
  
                 //HERE IS THE PROBLEM
                 //I want the Text to be Assigned to a Variable
                 //So I will put these code here
  
           /*
      AddressBookEntry entry = new AddressBookEntry (name, add, tel, email);
      list[top] = entry;
      top++;
  
           */
  
           //Yes list, top is getting the error here.. and It confuses me why?
  
          }
      });
      btnAccept.setBounds(119, 148, 89, 23);
      frame.getContentPane().add(btnAccept);
      frame.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[]      {frame.getContentPane(), lblName, lblAdress, lblPhoneNumber, lblEmailAddress,     textField, textField_1, textField_2, textField_3}));
  }
  
  }
  </code></pre>
  
  <p>How can I declare list and top to be recognized by the Add Entry Pop-up Window?</p>
  
  <p>Because It must be red by this class so I can show it in the Jlist later on ..</p>
  
  <p>AdressBookEntry Class (This is where the temp of the variables go, and'll be called)</p>
  
  <pre><code>package byDavid;
  
  import javax.swing.JTextField;
  
  public class AdressBookEntry {
  
  
  
  private JTextField name;
  private JTextField add;
  private JTextField  tel;
  private JTextField email;
  
  
  public AdressBookEntry(JTextField name, JTextField add, JTextField tel, JTextField email){
  this.name =  name;
  this.add = add;
  this.tel = tel;
  this.email = email;
  
  }
  
  
  
  public JTextField getName(){
  return name;
  }
  
  public void changeName(JTextField name){
  this.name = name;
  }
  
  public JTextField getAddress(){
  return add;
  }
  
  public void changeAddress(JTextField add){
  this.add = add;
  }
  
  public JTextField getTelNumber(){
  return tel;
  }
  
  public void changeTelNUmbe(JTextField tel){
  this.tel = tel;
  }
  
  public JTextField getEmailAdd(){
  return email;
  }
  
  public void changeEmailAdd(JTextField email){
  this.email = email;
  }
  
  }
  </code></pre>
  
  <p>I've searched many post,blog and etc. but I can't find specific answer.
  Please Explain it to me clearly, because I'm quite confused in Declaring the two, and their specific errors..</p>