java - GridBagLayout: how to keep invisible components from collapsing -
when making individual components of layout managed gridbaglayout invisible, arrangement of remaining components in layout keeps changing. gridbaglayout appears "collapse" cells invisible components, causing other components change positions. highly annoying behaviour, , i've been looking way keep doing that.
one method i've tried adding spacer same cell, fixed size equal preferred size of component may hidden, if preferred size ever change, lot of trouble keep spacer in sync. there better way?
actually, wouldn't bad if gridbaglayout disregard cells invisible components, still takes cell's insets account, if have layout of input fields , used insets neatly arrange them regular gaps in between, hiding 1 component in middle removes layout leaves gap, means surrounding components flow together, ugly double-wide gap between them...
what using jpanel (or box) placeholder?
put jpanel each cell , add components panels. if turn component invisible, panel should still there...
Comments
Post a Comment