//Load the pet images
String[] petStrings = {"Bird", "Cat", "Dog", "Rabbit", "Pig"};
images = new ImageIcon[petStrings.length];
for (int i = 0; i < petStrings.length; i++) {
images[i] = new ImageIcon("images/" + petStrings[i] + ".gif");
images[i].setDescription(petStrings[i]);
}
// Create the combo box
JComboBox petList = new JComboBox(images);
ComboBoxRenderer renderer= new ComboBoxRenderer();
renderer.setPreferredSize(new Dimension(200, 130));
petList.setRenderer(renderer);
petList.setMaximumRowCount(3);
// Layout the demo
setLayout(new BorderLayout());
add(petList, BorderLayout.NORTH);
setBorder(BorderFactory.createEmptyBorder(20,20,20,20));