what's easiest way make jpanel
takes fixed percentage of parent container, width?
its width should update when of parent container changes.
i tried using box.createhorizontalstrut()
, doesn't update when width of jpanel
's parent container changes.
what want gridbaglayout. (how use?)
using gridbaglayout allows define gridbagconstraints each single component add.
these constraints include weightx
says on tin. relative value calculated across components in "grid-row", similar distribution parts.
be aware weightx begins come play, when preferred size of components exceeded. aware may lead interesting bugs, when setting minimumsize(), see this answer.
anyways: can value need weightx specifying it's percentage across components in it's current row, or multiple of that.
this means component take 50% of available parent container width, use weightx = 0.5
. make sure row's weightx values add 1.0
Comments
Post a Comment