Java Utililty Methods JComponent Height

List of utility methods to do JComponent Height

Description

The list of methods to do JComponent Height are organized into topic(s).

Method

voidsetMaximumHeight(JComponent comp, int iHeight)
sets the maximum height of the given component (without changing its maximum width).
comp.setMaximumSize(new Dimension(getMaximumWidth(comp), iHeight));
JComponentsetMinimumHeight(JComponent component, int height)
set Minimum Height
component.setMinimumSize(new Dimension(component.getMinimumSize().width, height));
return component;
voidsetPreferredHeight(final JComponent component, final int height)
Sets the preferred height of the specified component.
component.setPreferredSize(new Dimension(component.getPreferredSize().width, height));
voidsetPreferredHeight(int height, JComponent... components)
Sets all specified components to the same height.
for (JComponent component : components) {
    component.setPreferredSize(new Dimension(component.getPreferredSize().width, height));
voidsetPreferredHeight(JComponent component, int height)
set Preferred Height
component.setPreferredSize(new Dimension((int) component.getPreferredSize().getWidth(), height));
JComponentsetZeroHeight(JComponent comp)
Sets the preferred height of a component to zero (0).
Dimension dims = comp.getPreferredSize();
dims.height = 0;
comp.setPreferredSize(dims);
return comp;
voidupdateComponentHeight(JComponent c)
update Component Height
for (Component child : c.getComponents()) {
    if (child instanceof JComponent) {
        updateComponentHeight((JComponent) child);
        child.setMinimumSize(child.getMinimumSize());
        child.setPreferredSize(child.getPreferredSize());
        child.setMaximumSize(child.getMaximumSize());