Java JComponent Size setComponentSize(JComponent comp, int width, int height)

Here you can find the source of setComponentSize(JComponent comp, int width, int height)

Description

set Component Size

License

Open Source License

Declaration

public static void setComponentSize(JComponent comp, int width, int height) 

Method Source Code

//package com.java2s;
/*/*from  w w w .  j a va 2  s  .  c  o m*/
 * Copyright (C) 2010, 2011, 2012 by Arne Kesting, Martin Treiber, Ralph Germ, Martin Budden
 *                                   <movsim.org@gmail.com>
 * -----------------------------------------------------------------------------------------
 * 
 * This file is part of
 * 
 * MovSim - the multi-model open-source vehicular-traffic simulator.
 * 
 * MovSim is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * MovSim is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with MovSim. If not, see <http://www.gnu.org/licenses/>
 * or <http://www.movsim.org>.
 * 
 * -----------------------------------------------------------------------------------------
 */

import java.awt.Dimension;

import javax.swing.JComponent;

public class Main {
    public static void setComponentSize(JComponent comp, int width, int height) {
        comp.setPreferredSize(new Dimension(width, height));
        comp.setMinimumSize(comp.getPreferredSize());
        comp.setMaximumSize(comp.getPreferredSize());
    }
}

Related

  1. sameSize(JComponent[] components)
  2. saveComponentSize(JComponent comp, Preferences prefs, String name)
  3. setAllSizes(JComponent component, int width, int height)
  4. setComponentSize(int width, int height, JComponent l)
  5. setComponentSize(JComponent comp, int defWidth, int defHeight, Preferences prefs, String name)
  6. setFixedSize(JComponent component, Dimension size)
  7. setFixedSize(JComponent component, Dimension size)
  8. setFixedSize(JComponent component, int width, int height)
  9. setMaximumSize(Dimension d, JComponent... components)