File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes Layout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Layout" Watch "Layout" New topic


Dean Kiely

Joined: Feb 27, 2004
Posts: 23
How do i go about having 3 panels ontop of a main panel and inside each of these panels i have 2 buttons on the left hand side and a canvas on the remaining part of the panel.
I am finding this tricky as the BorderLayout is very limited i.e north south east or west etc are the only choices available. How do i get around this??
Many thanks.
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

You will probably have to use a combination of layout managers. Look at the Java Tutorial's section on Swing, specifically Laying Out Components.

[How To Ask Questions On JavaRanch]
Dean Kiely

Joined: Feb 27, 2004
Posts: 23
I originally had one canvas but now i would like to have 3 panels and to have a canvas on each, is this possible or can i only have one canvas?
Rosie Vogel
Ranch Hand

Joined: Jan 31, 2001
Posts: 229
This is certainly possible, you can add a Canvas to your Applet and Panels to your Canvas and then add Buttons to the Panels, etc., etc., making a nested structure. Personally I like to use GridBagLayout to layout Applets. It's kind of comparable to using tables in HTML: every Component has it's own "cell" and you can have some Components stretch across more than one cell if you like. You can read more about it here:
Dean Kiely

Joined: Feb 27, 2004
Posts: 23
I was told that I could not add jpanels to a canvas, so instead I created a main Jpanel and added 3 jpanels to it, then i want to create a canvas in each jpanel, is this possible?? I had one main canvas but now i want to break it up to put different parts on each of the 3 jpanels.
I agree. Here's the link:
subject: Layout
It's not a secret anymore!