Placing JFrames inside JFrames

狂风中的少年 提交于 2020-01-15 11:59:41

问题


I'm working on an application that contains many JFrames, with the amateurish result that my program appears in the taskbar many times, one for each currently visible JFrame. I'm aware that JInternalFrame might solve my problem, but I've already made so many JFrames it's hard to switch! Is it possible to make my already-made JFrames appear within an overarching JFrame? Perhaps to somehow "transfer" each JFrame into a JInternalFrame?

What I ultimately want my application to look like is something akin to an Android app, with several "activities" that you can navigate like a browser.

Thanks


回答1:


Yeah, you could always get the contentPane from a JFrame and put it into the contentPane of a JInternalFrame (via the expected get and set methods), but it's many times not a good idea to try to add good code into a bad design. You may be better off refactoring your code and try to code towards the JPanel and not the JFrame. That way you'll have the flexibilty of placing your JPanels wherever you wish, be they JInternalFrames, JDialogs, JTabbedPane components, or swapped via CardLayout.




回答2:


alternatives, then you only to switch between JPanels

Use CardLayout examples here

Use Tabbed Panes and here



来源:https://stackoverflow.com/questions/6891868/placing-jframes-inside-jframes

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