Java JComponent Size setFixedSize(JComponent component, int width, int height)

Here you can find the source of setFixedSize(JComponent component, int width, int height)

Description

Set the fixed size to given component.

License

Open Source License

Parameter

Parameter Description
component the component to set
width the fixed width
height the fixed height

Declaration

public static void setFixedSize(JComponent component, int width, int height) 

Method Source Code


//package com.java2s;
import java.awt.Dimension;

import javax.swing.JComponent;

public class Main {
    /**/*from w  w w.  j a  v a  2 s.  com*/
     * <p>
     * Set the fixed size to given component.
     * </p>
     * @param component the component to set
     * @param width the fixed width
     * @param height the fixed height
     * @since 1.1
     */
    public static void setFixedSize(JComponent component, int width, int height) {
        Dimension size = new Dimension(width, height);
        component.setMaximumSize(size);
        component.setMinimumSize(size);
        component.setPreferredSize(size);
    }
}

Related

  1. setComponentSize(int width, int height, JComponent l)
  2. setComponentSize(JComponent comp, int defWidth, int defHeight, Preferences prefs, String name)
  3. setComponentSize(JComponent comp, int width, int height)
  4. setFixedSize(JComponent component, Dimension size)
  5. setFixedSize(JComponent component, Dimension size)
  6. setMaximumSize(Dimension d, JComponent... components)
  7. setMaximumSize(Dimension maxComponentSize, JComponent component)
  8. setMaxPreferredSize(JComponent comp)
  9. setMinimumSize(JComponent component, int numChars)