title: Java Swing - set Jlabel text from another method
body: <p>I'm pretty new to Java and Swing, and I'm using Windowbuilder to play around with a few GUI ideas I have, but I've run into a problem when trying to set the text of a Jlabel.</p>
  
  <p>Windowbuilder has automatically created an instance of the Jlabel, called pathLabel, in the initialize() method like so:</p>
  
  <pre><code>private void initialize() {
      frame = new JFrame();
      frame.setBounds(100, 100, 570, 393);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().setLayout(null);
  
      JLabel pathLabel = new JLabel("New label");
      pathLabel.setBounds(61, 296, 414, 15);
      frame.getContentPane().add(pathLabel);}
  </code></pre>
  
  <p>If I use pathLabel.setText("enter text here") from within this initialize() method, then it works fine, but how can I set text from a completely different method? It's not letting me reference it.</p>
  
  <p>I never had this problem in Visual Studio with C#, and was able to set the text of a label from any method I choose. What am I missing?</p>
  
  <p>I hope this makes sense, and I appreciate any help at all. Thanks.</p>