Java JComponent Height setPreferredHeight(final JComponent component, final int height)

Here you can find the source of setPreferredHeight(final JComponent component, final int height)

Description

Sets the preferred height of the specified component.

License

Open Source License

Parameter

Parameter Description
component The component
height The preferred height

Declaration


public static void setPreferredHeight(final JComponent component, final int height) 

Method Source Code

//package com.java2s;
/*/*  www.  j a v a  2  s.c  o  m*/
 * Copyright (C) 2009 Klaus Reimer <k@ailis.de> 
 * See LICENSE.md for licensing information.
 */

import java.awt.Dimension;

import javax.swing.JComponent;

public class Main {
    /**
     * Sets the preferred height of the specified component.
     *
     * @param component
     *            The component
     * @param height
     *            The preferred height
     */

    public static void setPreferredHeight(final JComponent component, final int height) {
        component.setPreferredSize(new Dimension(component.getPreferredSize().width, height));
    }
}

Related

  1. sameHeight(JComponent[] components, int height)
  2. setComponentHeight(JComponent setme, JComponent getme)
  3. setMaxHeightToPreferred(JComponent component)
  4. setMaximumHeight(JComponent comp, int iHeight)
  5. setMinimumHeight(JComponent component, int height)
  6. setPreferredHeight(int height, JComponent... components)
  7. setPreferredHeight(JComponent component, int height)
  8. setZeroHeight(JComponent comp)
  9. updateComponentHeight(JComponent c)