force JComponent Size - Java Swing

Java examples for Swing:JComponent

Description

force JComponent Size

Demo Code


//package com.java2s;

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);/*from  ww w .j ava  2 s .  c  o  m*/
        component.setMaximumSize(d);
        component.setPreferredSize(d);
    }
}

Related Tutorials