File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes arranging display in a panel with grid bags... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "arranging display in a panel with grid bags..." Watch "arranging display in a panel with grid bags..." New topic

arranging display in a panel with grid bags...

achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
I have done a setLayout(new GridLayout(2,2)) in order to get 4 panels. 2 rows by 2 columns.
In the row1/col1 (NORTHWEST) is a block of data in tabular format.
In the row1/col2 there should be an image.
In row2 there should be a text area spanning both columns.
Somehow, my current arrangement has got a bit of the image displayed on the right hand side of row 2 text area.
How do I force the image to display in a panel in row1/col2 ???
Yes doing it right the first time is diffcult, after that, I get remarks from colleagues reading and copying my codes, saying "...that looks easy, I knew that... ".
Basically, if I have a 3x4 grid than how do I ensure that panel ABC is in row1, col2 ???
Arrrgggh, all these books have such simple examples, like setLayout(new GridLayout(1,2)).

[ December 10, 2002: Message edited by: achana chan ]

humanum errare est.
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Instead of using GridLayout, you should be using GridBagLayout...

Here's a short example showing a frame layed out like you described...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: arranging display in a panel with grid bags...
It's not a secret anymore!