Here you can find the source of getPreferredSize(JComponent component, int width)
Parameter | Description |
---|---|
component | The component providing the preferred height. |
width | The preferred width. |
public static Dimension getPreferredSize(JComponent component, int width)
//package com.java2s; //License from project: Apache License import java.awt.Dimension; import javax.swing.JComponent; public class Main { /**/*from w w w . j a v a 2 s.co m*/ * Returns the preferred dimensions of a component, using the current height * and a custom width. * @param component The component providing the preferred height. * @param width The preferred width. * @return The preferred dimension. */ public static Dimension getPreferredSize(JComponent component, int width) { Dimension dim = component.getPreferredSize(); return new Dimension(width, dim.height); } }