Here you can find the source of forceSize(JComponent component, int width, int height)
public static void forceSize(JComponent component, int width, int height)
//package com.java2s; //License from project: Apache License import java.awt.Dimension; import javax.swing.JComponent; public class Main { public static void forceSize(JComponent component, int width, int height) { Dimension d = new Dimension(width, height); component.setMinimumSize(d);//w w w.ja va2s . com component.setMaximumSize(d); component.setPreferredSize(d); } }