Two JFrames in one Runnable. First JFrame disappears in the application bar after calling a JFileChooser

心已入冬 提交于 2019-12-23 05:58:09

问题


I'm trying to create a multi-windowed interface, ala GIMP. One of them allows the user to load an image, to be displayed in the frame. So, when the program loads, all windows (two for now but I plan to have three) are shown in the application bar. However, when the second* window invokes JFileChooser, it disappears in the application bar (but does not close). But if I <Super>+<Tab> or <Alt>+<Tab> it still appears there. It also reappears in the app bar when I click the "Show/Hide All Windows" button.

All JFrames are invoked from a single Runnable. Anyone else encountered this issue? How do I work around this one (i.e., make all windows visible in the application bar at all times)?

Thanks!

*I called it the second window since it is the second one that is setVisibled to true.


回答1:


A JFrame will appear on the task bar. A JWindow or JDialog do not appear on the task bar.

A JFileChooser uses a JDialog to display the date so it will not appear on the task bar. You need to specify a JFrame as the owner of the file chooser. The file choose will still not appear on the task bar, but when you click on the icon representing the owner frame it will become visible along with the frame.



来源:https://stackoverflow.com/questions/7526765/two-jframes-in-one-runnable-first-jframe-disappears-in-the-application-bar-afte

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!