Here you can find the source of makeComboBox(Object[] items)
public static JComboBox makeComboBox(Object[] items)
//package com.java2s; //License from project: Open Source License import java.awt.*; import javax.swing.*; public class Main { /** Creates a combo box that remains one line in height. */ public static JComboBox makeComboBox(Object[] items) { return new JComboBox(items) { public Dimension getMaximumSize() { Dimension pref = getPreferredSize(); Dimension max = super.getMaximumSize(); return new Dimension(max.width, pref.height); }//from ww w .ja va 2 s . com }; } }