简体   繁体   中英

How to make JDialog top-most but not modal?

I'm creating an applet. That applet has to take some big chunks of data from the db and that operation is slow... That's why I would like to create a "loading" JDialog that will be shown on top of the applet while the applet is loading data from the DB, BUT it shouldn't block user input to applet.
How to do it? If I create a JDialog that is "setAlwaysOnTop(true)" it won't show on top. If I set it to modal it will show but it won't allow my applet to communicate with DB. I even tried to make that "loading" window runnable and run it from another thread, no luck.

How to make proper, universal, "loading" JDialog for applet that WON'T be modal, but will stay always on top?

It is generally a very (and i mean very very) bad idea to call swing/awt from a non EDT thread. Be awere, there are numerous issues with how applet JFrame/JDialog work in OSX and Windows. IMO it would make for much better user experience if your applet just used JProgressBarr or something in your applets UI directly. If you absolutely have to pop up a window, use JFrame with AlwaysOnTop=true . The reason you are getting weird behavior is that you probably not using constructor that takes parent component or simply pass in a null value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM