java - Change the jprogressbar in an other class -


I have found a project and I want to change the value of the progress bar with the calls of another class. How can it execute?

  Improves the Stable Class Button ActionList Method {@ Override Public Voice ActionPerfed (Action Event E) {New Thread (New Runnabal) {@Override Public Zero Run (for (Int i = 1; i & lt; = bar.getMaximum (); ++ i) {last int j = i; SwingUtilities.invokeLater {@Override Public Zero Run} {bar.setValue (j);}}) ; }         }       } ).Start(); }}  

you bar.setValue (...) To change progress.

However, be careful that you can safely do this with code that swings to the Event Listener thread. Calling this method from any other thread leads to unfinished failures which are only occasionally done, are working hard to test, and are hard to track down.

Using SwingUtilities.invokeLater (...) The right approach to change is that you can do with any code in which bar Access to the context is, for example, you can highlight it through the recipient.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -