Jpanels, panes, containers and other stuff

Okay in theory im hoping this is going to work. I set my applet to be 640 x 480 for the game screen. This screen is sectioned into 4 panes.

I am making each pane as a seperate class and hoping to add it to the container on the main class with each pane adding its own stuff to itself (buttons, strings, images, etc) and will be using GridBag Layout as each pane is a different size and doesn’t do a 2,2 layout.

But. Since I am a n00b at java and know very little cause of experience. Im not sure if this is going to work. Does this sound like a right track or do i need to use the contructor and init() stuff on the main class to build and add items to each pane?

Sounds like you are doing ti right.

Yes, sounds good. However, I noticed you mentioned “GridBagLayout”.
Pretty much all the layout classes provided with the Java Standard package
are rather weak!

I stopped using them some time ago. The way to go is the “FormLayout”
class. You can find it at http://www.jgoodies.com/freeware/forms/index.html.
You can very flexible define the cell sizes etc. Same if you want to add buttons
and text to a panel.

Holy cow that looks neat. Imma check it out and see if it’ll work for me. Learning more stuff all the time!

Im sure ill have much for questions after reading more into it!

Yep! It’s cool. Also, it’s much better than wasting your time with the standard java layout classes!
Don’t use GridLayout, GridBagLayout … they just suck.

After reading the site for this… im not sure how to implement this system? Any pointers. all i see are free downloads which give me examples but not sure if i just use their code and change stuff or is this a language i integrate into eclipse

You do NOT need Eclipse. You can use the classes by themselves. For the layout,
just put “jgoodies-forms.jar” (or something like that) into your classpath. The “forms”
jar contains the layout classes.

The article is little bit hidden, but here it is (you should skim through it so you get the
idea):
http://www.jgoodies.com/articles/forms.pdf

And here how it would look to layout some stuff:


FormLayout layout = new FormLayout(
    “pref, 4dlu, 50dlu, 4dlu, min”, // columns
    “pref, 2dlu, pref, 2dlu, pref”); // rows
JPanel panel = new JPanel(layout);
CellConstraints cc = new CellConstraints();

panel.add(new JLabel(“Label1”), cc.xy (1, 1));
panel.add(textField1, cc.xyw(3, 1, 3));
...

I didn’t use the “look” package for look & feel. But there should be some info on their
web site as well.