Java JComponent Height setMaxHeightToPreferred(JComponent component)

Here you can find the source of setMaxHeightToPreferred(JComponent component)

Description

Sets the maximum size of a JComponent to the preferred size

License

Open Source License

Parameter

Parameter Description
component The component to set the size of

Declaration

public static void setMaxHeightToPreferred(JComponent component) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Dimension;

import javax.swing.JComponent;

public class Main {
    /**/*  ww  w. j a  v a  2  s  . c o m*/
     * Sets the maximum size of a {@link JComponent} to the preferred size
     * 
     * @param component
     *            The component to set the size of
     */
    public static void setMaxHeightToPreferred(JComponent component) {
        component.setMaximumSize(new Dimension(Integer.MAX_VALUE, component.getPreferredSize().height));
    }
}

Related

  1. heighten(JComponent component, int px)
  2. makeEqualHeight(JComponent reference, JComponent... others)
  3. normalizeHeight(JComponent... components)
  4. sameHeight(JComponent[] components, int height)
  5. setComponentHeight(JComponent setme, JComponent getme)
  6. setMaximumHeight(JComponent comp, int iHeight)
  7. setMinimumHeight(JComponent component, int height)
  8. setPreferredHeight(final JComponent component, final int height)
  9. setPreferredHeight(int height, JComponent... components)