Problems with GridBagLayout

Hey,

I would like to know if there is a way to make a grid without having dependencies between the lines. Basicly, I don't want a single item influencing the size of the whole column of my grid.

The problem I am having is that the first item that I add to my grid is a long label. Then, on the second line of my grid, I need to add two items, but the second item is aligned with the end of the label on my first line (end of the first column) and I do not want that.

Being able to create a grid inside another grid would probably work, but I don't know how to do so.

Thanks for the help.

[620 byte] By [FManseaua] at [2007-10-3 8:29:15]
# 1

The easiest way to design a GUI is to use multiple layouts and nest them as required. So maybe you use a panel with a BoxLayout. Then you create a panel with a FlowLayout and add it to the BoxLayout. Then you create a second panel with a FlowLayout and add it to the BoxLayout. Now you have two independent rows.

Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use Layout Managers[/url] to understand how each one works and then mix and match as appropriate.

camickra at 2007-7-15 3:36:05 > top of Java-index,Desktop,Core GUI APIs...
# 2
so there is no grid or class that allowd to have indepedant rows....thats weird
FManseaua at 2007-7-15 3:36:05 > top of Java-index,Desktop,Core GUI APIs...
# 3

> so there is no grid or class that allowd to have

> indepedant rows....thats weird

When a single layout manager does layout controll over a full container, we implicitly

expect a kind of dependency among components laid out, more or less. Layout is a

design of dependency among elements in a single finite universe.

As camickr has pointed it out, however, different layout managers working on different

containers are, by its nature or definition, should be independent each other that would

fulfill your requirement.

We don't need to expect everything we want on a mere single feature of a finite system.

We can do almost anything by composition.

hiwaa at 2007-7-15 3:36:05 > top of Java-index,Desktop,Core GUI APIs...
# 4
You could make the long label span across 2 columns. However, since you haven't provided any GBL code, it's impossible for us to guess what you're doing wrong.
KelVarnsona at 2007-7-15 3:36:05 > top of Java-index,Desktop,Core GUI APIs...