GridLayout and Fill

B

Berlin Brown

Normally this stupid GridLayout fills the entire area, now I cant find
the code to do that. I am trying to fill a panel which is 500,400 and
these buttons only fill their respective widths and heights, does it
matter what windowing system I am on for layouts to do different things
or am I missing something, jdk1.4.1.


Ideally, I though _c.fill = BOTH was supposed to fill all the way across?

GridBagConstraints _c = new GridBagConstraints();
_c.anchor = GridBagConstraints.NORTH;

_c.fill = GridBagConstraints.BOTH;
_c.gridwidth = GridBagConstraints.REMAINDER;
saveLabel("Text", _c);

_c.fill = GridBagConstraints.HORIZONTAL;
_c.gridwidth = 3;
saveLabel("The Edit Box", _c);
saveLabel("Submit", _c);
saveLabel("Clear", _c);


// end of the panel

} // end of the function

private void saveLabel(String _val, GridBagConstraints c) {

Button _button = new Button(_val);

_gb.setConstraints(_button, c);

_mainPanel.add(_button);

} // end of the fucntino
 
B

BarryNL

Berlin said:
Normally this stupid GridLayout fills the entire area, now I cant find
the code to do that. I am trying to fill a panel which is 500,400 and
these buttons only fill their respective widths and heights, does it
matter what windowing system I am on for layouts to do different things
or am I missing something, jdk1.4.1.


Ideally, I though _c.fill = BOTH was supposed to fill all the way across?

GridBagConstraints _c = new GridBagConstraints();
_c.anchor = GridBagConstraints.NORTH;

_c.fill = GridBagConstraints.BOTH;
_c.gridwidth = GridBagConstraints.REMAINDER;
saveLabel("Text", _c);

_c.fill = GridBagConstraints.HORIZONTAL;
_c.gridwidth = 3;
saveLabel("The Edit Box", _c);
saveLabel("Submit", _c);
saveLabel("Clear", _c);

Too lazy to test it here, but I think you need _c.weightx = 1.0 and
_c.weighty = 1.0 as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top