Here you can find the source of setSize(JComponent component, int width, int height)
public static void setSize(JComponent component, int width, int height)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; public class Main { public static void setSize(JComponent component, int width, int height) { Dimension textPanelSize = new Dimension(width, height); component.setSize(textPanelSize); component.setPreferredSize(textPanelSize); component.setMaximumSize(textPanelSize); component.setMinimumSize(textPanelSize); }//from ww w. j a v a2 s. co m }