Here you can find the source of setMaxHeightToPreferred(JComponent component)
Parameter | Description |
---|---|
component | The component to set the size of |
public static void setMaxHeightToPreferred(JComponent component)
//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)); } }