Here you can find the source of setPreferredWidth(final JComponent component, final int width)
Parameter | Description |
---|---|
component | The component |
width | The preferred width |
public static void setPreferredWidth(final JComponent component, final int width)
//package com.java2s; /*// ww w .jav a 2 s. co m * Copyright (C) 2010-2012 Klaus Reimer <k@ailis.de> * See LICENSE.TXT for licensing information. */ import java.awt.Dimension; import javax.swing.JComponent; public class Main { /** * Sets the preferred width of the specified component. * * @param component * The component * @param width * The preferred width */ public static void setPreferredWidth(final JComponent component, final int width) { component.setPreferredSize(new Dimension(width, component.getPreferredSize().height)); } }