0

I need to make a Java desktop application for a client and the last time I did Java it was 2 years ago and a little odd.

My main query is regarding navigation between GUI. In the past, I would just create a new JForm (JFrame maybe?) whenever a button was pressed and a new GUI form/window would open up.

This time, I'd like the GUI to be inside one JForm/JFrame with just the inner content changing, how most applications look when you press a button.

I assume this is done by putting all of my GUI elements in JPanels, and deleting/creating them when buttons are pressed on the same JForm? If not how do I do it properly?

I'll also be using Netbeans GUI editor, if anyone has a better alternative for a Java GUI builder/IDE, let me know. Thanks!

Chris G
  • 449
  • 1
  • 5
  • 19
  • 3
    `if anyone has a better alternative for a Java GUI builder/IDE,` build your GUI's manually then 1) you can move your code from IDE to IDE and 2) you learn Java instead of learning the IDE. – camickr Dec 19 '13 at 03:02

2 Answers2

2

The simplest approach would be to use a CardLayout

This will allow you to add multiple components to the UI and control which one is actively visible

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
-1

Another approach could be to create menus and menuItem and having multiple JFrames now you can get the same JFrame to be displayed whenever you click the same menuItme button. This way You can minimize the creation of JFrames.

Vijay
  • 213
  • 1
  • 9
  • -1, An application should only have a single JFrame. For a child window you would typically use a JDialog. See: http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice – camickr Dec 19 '13 at 03:08
  • @camickr: Thanks a lot for the link for a great opinions. – Vijay Dec 19 '13 at 04:12