问题
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