title: java, get set methods
body: <p>This question has been asked before, but even after reading: </p>
  
  <p><a href="https://stackoverflow.com/questions/23189672/java-get-and-set-methods">Java &quot;Get&quot; and &quot;Set&quot; Methods</a></p>
  
  <p><a href="https://stackoverflow.com/questions/20854514/java-get-set-method-returns-null">Java Get/Set method returns null</a></p>
  
  <p>And more I still don't understand how to solve my problem.</p>
  
  <p>When accessing variables in a class using get methods from another class I receive the value null. </p>
  
  <p>How do I recieve my correct values instead of null? </p>
  
  <hr>
  
  <p>This is the class where I try to get my variables FROM (not everything included). </p>
  
  <pre><code>public class RLS_character_panel extends javax.swing.JPanel implements ActionListener, ItemListener { 
  
      private String name1 = "hello"; 
  
      public String getName1() { 
          return name1; 
      } 
  
      public void setName1(String name1) { 
          this.name1 = name1; 
      } 
  
  } 
  </code></pre>
  
  <hr>
  
  <p>This is the class where i try to get the values TO. This class extends JFrame so that I can add a JPanel which displays the variable. (the JPanel is  yet another class called: RLS_strid_panel , which is added upon this frame). </p>
  
  <pre><code>public class RLS_strid_java extends JFrame { 
  
      RLS_character_panel test = new RLS_character_panel(); 
  
      String name1 = test.getName1(); 
  
      RLS_strid_panel p = new RLS_strid_panel(namn1); 
  
      // constructor
      public RLS_strid_java(String titel) { 
          super(titel); 
          this.setSize(1000, 772); 
          this.setVisible(true); 
          this.setResizable(false); 
          this.add(p); 
      } 
  }
  </code></pre>
  
  <hr>
  
  <p>the Jpanel Displays null.</p>