title: How to update JLabel from action listener?
body: <p>Explanation:</p>
  
  <hr>
  
  <p>I have an int variable to keep track of how many times button is pushed. </p>
  
  <p>I have a JLabel that shows this variable in the form of a string basically.</p>
  
  <p>When I click Add, I want the variable to update and then the jlabel to show the updated variable.</p>
  
  <p>I have a secondary button listener class that implements the actionlistener code. I can't post all my code because my professor is strict about her plagiarism checks.</p>
  
  <p>EDIT:</p>
  
  <p>I see when I add the JLabel.setText to the action listener, it will update. Not sure if this is the best method. </p>
  
  <p>Code:</p>
  
  <hr>
  
  <pre><code>int counter = 0;
  
  JLabel label = new JLabel("Count is: " + counter);
  
  JButton increment = new JButton("Increment Here");
  
  increment.addActionListener(new ButtonListener());
  </code></pre>
  
  <p>My button listener class contains this code:</p>
  
  <pre><code>counter++;
  </code></pre>
  
  <p>Let me know if more code is necessary, I am just trying to simplify my issue. I tried adding an UpdateUI(); method, but nothing happened.</p>