2

I'm trying to create an application in Java and I'm not sure about how to go about creating a screen that will then load another screen, for example a menu screen that when you click a button will load another screen and stop loading the menu screen. What would be the professional way of doing this?

I had the idea of creating different JFrame windows and then using jfrm.dispose() and new jfrm.setVisible(true), however when doing this there is a split second where there is nothing loaded at all and it doesn't look like a professional app, also I've read that using multiple frames is bad.

I could use different panels and load them when required onto the same frame. Or is there another more efficient way?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
w13rfed
  • 355
  • 5
  • 12
  • *"..I've read that using multiple frames is bad."* For the best link on that, see.. [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Apr 15 '16 at 11:11

1 Answers1

3

You need to use JInternalFrame.

  • Use JFrame as the main window.
  • Add JDesktopPane below the main menu.
  • Use tabbed pane to add tabs. To add tabs to the tabbed pane refer to this answer.

Use the method addOnScreen(JInternalFrame inFrame, String title) to add the internal frame as a tab with a title.

Community
  • 1
  • 1