Is there a way we can get the UI code cleaner
Originally posted by Can Zheng:
After using a layout manager I still need to hard code the components prefered/minimum/maximum size in many cases, and I'm quite uncomfortable with that. Is there a way we can get the UI code cleaner?
I think in many cases you cannot avoid setting some preferred sizes
Each component managed by a GridBagLayout is associated with an instance of GridBagConstraints. The constraints object specifies where a component's display area should be located on the grid and how the component should be positioned within its display area. In addition to its constraints object, the GridBagLayout also considers each component's minimum and preferred sizes in order to determine a component's size.
A flow layout lets each component assume its natural (preferred) size.
The components are laid out according to their preferred sizes and the constraints of the container's size. The NORTH and SOUTH components may be stretched horizontally; the EAST and WEST components may be stretched vertically; the CENTER component may stretch both horizontally and vertically to fill any space left over.