-2

I am very new to java programming and SwingGUI. I am currently trying to creatte a clicker game using swing. I need to update the text of a jlabel constantly to a pre-defined variable. I have looked around and cannot seem to find a clear answer on how to update the GUI or component constantly or after a set interval.

1 Answers1

1

Use a Swing Timer.

Read the section from the Swing tutorial on How to Use Timers for more information and working examples.

Another simple example: Update a Label with a Swing Timer

Community
  • 1
  • 1
camickr
  • 321,443
  • 19
  • 166
  • 288
  • Timer timer = new Timer(1000, this); timer.setInitialDelay(1); timer.start(); { //Code Here } Is This The Correct Format? – Lewis Solarin Apr 19 '17 at 19:50
  • @LewisSolarin, you tell me? Try it! We are not here to write the code for you, only point you in the right direction. You were given a link to a tutorial and another question that contains working example. Read the tutorial. Download and test the code from the linked example. You learn by trying. If you still have a problem, then post an [mcve] demonstrating the problem. And don't post the code in a comment since it is not readable. Post the ~MCVE` in the question. – camickr Apr 19 '17 at 19:55