Java examples for Swing:JComponent
set Component Size
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { public static void setComponentSize(int width, int height, JComponent l) { l.setPreferredSize(new Dimension(width, height)); l.setMinimumSize(new Dimension(width, height)); if (l instanceof JTextField || l instanceof JComboBox) { l.setMaximumSize(new Dimension(Short.MAX_VALUE, height)); }/* www . j a v a 2 s. c o m*/ } }