1

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

mKorbel
  • 109,525
  • 20
  • 134
  • 319

2 Answers2

2

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.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • Thanks very much! Come to think of it, it shouldn't take too long, since most of the information is in JPanels within JFrames anyway. –  Jul 31 '11 at 20:30
  • +1 See also this [example](http://groups.google.com/group/comp.lang.java.programmer/msg/2e1b14bcad9bd7fa). – trashgod Jul 31 '11 at 23:48
2

alternatives, then you only to switch between JPanels

Use CardLayout examples here

Use Tabbed Panes and here

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • +1 See also this [example](http://stackoverflow.com/questions/6432170/how-to-change-ui-depending-on-combo-box-selection/6432291#6432291). – trashgod Jul 31 '11 at 23:47