title: Accessing the components from another class
body: <p>I am very new to java.  </p>
  
  <p>I have a class where i am creating gui and another class (main class), i am accessing the gui class.  In the gui class i am creating some components and returning them.</p>
  
  <p>gui class,</p>
  
  <pre><code>        public class Gui {
  
              public Component getTopPanelContent(){
                  Jpanel jp = new Jpanel();
                  JComboBox cbo1 = new JComboBox();
                  JComboBox cbo2 = new JComboBox();
                  JComboBox cbo3 = new JComboBox();
                  JComboBox cbo4 = new JComboBox();
                  JComboBox cbo5 = new JComboBox();
                  JButton button = new JButton();
  
                  jp.add(cbo1);
                  jp.add(cbo2);
                  jp.add(cbo3);
                  jp.add(cbo4);
                  jp.add(cbo5);
                  jp.add(button);
                  return jp; 
              }
          }
  </code></pre>
  
  <p>main class,</p>
  
  <pre><code>        public void addComponents(int id){
             Gui g = new Gui();
             Jpanel container = new Jpanel();
  
             if(id == 1){
                 container.add(g.getTopPanelContent);     
             }
          }
  </code></pre>
  
  <p>upto this its working fine.</p>
  
  <p>In the main class there is a JTextArea,  Whenever i open a file, i have to display the country list in cbo1, the file contains the list of countries that has to be displayed,</p>
  
  <pre><code>       String[] countries = editArea.getContents().split("\n");
  </code></pre>
  
  <p>How to pass the country values to cbo1</p>
  
  <p>Thanks</p>