java - Resizing cell in GridLayout -


like title suggests, want resize grid components if there small component inside of grid remove excess space.

here's example of looks like:

what looks like.

instead should this:

this.

i'm using gridlayout. looks kinda like:

grid = new jpanel(new gridlayout(1, 3)); grid.add(jpanel1); grid.add(jpanel2); grid.add(jtextfield);` 

any ideas?

edit: fixed problem using miglayout(thanks @blip) , overriding preferred size. blip told me not override, rather use miglayout's additional functionality same results. while work, decided change height of jtextfield. otherwise use other solution. help!

all other ones shrink jtextfield 1 px wide.

no don't. first of make sure create text field code like:

jtextfield textfield = new jtextfield(10); 

the number text field determine reasonable preferred size.

you use flowlayout, respects preferred size.

or use gridbaglayout more flexible, more complicated use. yes, when use gridbaglayout, if shrink fame small, components displayed @ minimum size, few pixels text field.

the key use frame.pack() components displayed @ preferred size don't have worry components shrinking.

read swing tutorial on layout managers more information.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -