title: Display text to a label from another class - JFrame
body: <p>I have a GUI screen, and it has a label in it. I now want to set the label with a text as i have shown in below (<code>Test</code>). But it's not getting updated. I think there's an error in the follwoing code, where i am recreating a new object of FrameTest in the try block;</p>
  
  <pre><code>FrameTest frame = new FrameTest();
  frame.setVisible(true); //(the full code given below)
  </code></pre>
  
  <p>The Full Code: Note: the following class is extended from <strong>JFrame</strong></p>
  
  <pre><code>import java.awt.BorderLayout;
  
  public class FrameTest extends JFrame {
  
      private JPanel contentPane;
      private JLabel lblLabel;
  
      public  void mainScreen() {
          EventQueue.invokeLater(new Runnable() {
              public void run() {
                  try {
                      FrameTest frame = new FrameTest();
                      frame.setVisible(true);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          });
      }
  
  
      public void writeLabel(String k){
          this.lblLabel.setText(k);
  
      }
  
  
      public FrameTest() {
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setBounds(100, 100, 450, 300);
          contentPane = new JPanel();
          contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
          contentPane.setLayout(new BorderLayout(0, 0));
          setContentPane(contentPane);
  
          lblLabel = new JLabel("LABEL");
          contentPane.add(lblLabel, BorderLayout.CENTER);
      }
  
  }
  </code></pre>
  
  <p>Test Class</p>
  
  <pre><code>public class Test {
  
      public static void main(String[] args) {
  
           FrameTest f = new FrameTest();
           f.mainScreen();
           f.writeLabel("FFFFF");
  }}
  </code></pre>
  
  <p>Help, how can i get Text <code>"FFFFF"</code> displayed to the label ?</p>