dcsimg
GridBagLayout problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   matthew_smith
Posted On:   Monday, September 2, 2002 08:26 AM

I'm trying to layout some components using GridBag but I can't get it quite right. Here's what I want: __________________________________ | _______________ _______________ | | |             ||                || | |              ______________|| || | ______________ |               || | |              ||               || | |              ||               || | |              ||               || | |              ||               || | |              ||______________|| | |              ||________________| | |______________||______________|| |________   More>>

I'm trying to layout some components using GridBag but I can't get it quite right.


Here's what I want:



__________________________________
| _______________ _______________ |

| |             ||                ||

| |              ______________|| ||

| ______________ |               ||

| |              ||               ||

| |              ||               ||

| |              ||               ||

| |              ||               ||

| |              ||______________||

| |              ||________________|

| |______________||______________||

|_________________________________|


Basically four panels in two columns with the top left and bottom right panels being at their minimum size (ish) and the other two taking up whatever space they need.


The problem is I can't get the bottom left panel to stay small (it will contain ok/cancel buttons).


I've been trying to have a 3x2 grid so that the top left panel is in (0,0) the bottom left starts in (0,1) and takes up two rows. Top right is in (1,0) and takes up two rows, bottom right in (1,2).

Rows two and three always end up the same height (half the height of the bottom left component) rather than row three at only the height of the bottom right component.


I've tried lots of variations of weights and gridheights etc. but no joy!

   <<Less

Re: GridBagLayout problem

Posted By:   Dmytro_Vorobyov  
Posted On:   Monday, September 9, 2002 12:16 AM

I add the OK button to bottom of form :
(but it must be the last add operation)




...........

JButton saveValues = new JButton("Save");
..............

gridBagConstraintsLabel.gridx=1; // the last column
gridBagConstraintsLabel.gridy=GridBagConstraints.RELATIVE; // the last row
gridBagConstraintsLabel.gridwidth=1;
gridBagConstraintsLabel.gridheight=1;
gridBagConstraintsLabel.fill =GridBagConstraints.NONE;
gridBagConstraintsLabel.anchor =GridBagConstraints.EAST;
gridBagConstraintsLabel.insets=new Insets(5,0,0,0);

About | Sitemap | Contact