Mike Warren
Mike Warren

Reputation: 3866

containers to use for JTabbedPanes

I am developing a math game and I was thinking about displaying the data like so:

  1. Display the data that the user is to screencap and send to me, in a JFrame. This data will be displayed in the form of two JTabbedPanes, each tab showing a table (with five rows and 8 columns)
  2. Ask the user (via JOptionPane.showConfirmDialog()) if they would like to see a graphical representation of their progress.
  3. If they click "Yes", then show them a JFrame with their chart. This JFrame will have a JMenuBar with only one JMenu with two JMenuItems (an option for both of the two modes).
  4. In this new JFrame, display via CardLayout the active JTabbedPane (the FloatMode has four difficulties, while the IntMode has all the FloatMode's difficulties plus Elementary School difficulty.

I know that multiple JFrames can be bad practice, and I was thinking about using JSplitPanes, but then it might get too crowded (and I wouldn't be able to let the users choose the mode!). Would a JDialog be recommended, or would you recommend something else? //I apologize if it sounds like I am asking you all to do some of my thinking for me...

Upvotes: 1

Views: 50

Answers (2)

Andrew Thompson
Andrew Thompson

Reputation: 168825

Seems best suited to a CardLayout with a single control to select between cards (e.g. a JList or JComboBox, JSpinner, menus etc.).

E.G. as seen in this short example, that uses radio buttons in a button group to select the card.

Upvotes: 1

Mike Warren
Mike Warren

Reputation: 3866

I might have a potential solution: make the JMenuBar universal! That would eliminate the need for two JTabbedPanes and thus speed up performance (due to less Objects floating around, especially expensive GUI Objects)!

Upvotes: 0

Related Questions