Swing Application Task

I am developing a Swing application and everything is working fine. But I have a problem with the GUI.

When I launch the application and, for example, minimize another window, my application still works, but the central part is JFrameinvisible or hidden. After completing any part of the program logic, the GUI is repainted and displayed again. This will continue until the program ends.

Is there any API to prevent this behavior, or some class to force the GUI to be displayed, or perhaps to add some kind of progress bar?

If anyone needs this information, I am testing this on Windows Vista with java 1.6.

+3
source share
3 answers

It seems to me that you are doing some kind of slow IO or calculations that make your GUI become unresponsive.

What you need to do is lengthy processes in another thread.

The standard way to do this is with SwingWorkerclass.

The Java tutorials contain several useful resources and guidelines for their proper use SwingWorker.

Here and here there is a link to another question, which, I believe, may be similar.

, , , , . , , JFrame, .

+9

jinguy, , , , . Java Sun Concurrency Swing. , .

+2

, - . SwingWorker.

.

+2
source

Source: https://habr.com/ru/post/1711260/


All Articles