Here you can find the source of createComboBox(String actionCommand, ActionListener listener, String... items)
@SuppressWarnings({ "rawtypes", "unchecked" }) public static JComboBox createComboBox(String actionCommand, ActionListener listener, String... items)
//package com.java2s; /*/*from ww w .j a v a2 s . c o m*/ * CS 106A * * This instructor-provided file contains utility functions related to GUIs. * * Author : Marty Stepp * Version: Tue 2014/06/05 * * This file and its contents are copyright (C) Stanford University and Marty Stepp, * licensed under Creative Commons Attribution 2.5 License. All rights reserved. */ import java.awt.event.*; import javax.swing.*; public class Main { @SuppressWarnings({ "rawtypes", "unchecked" }) public static JComboBox createComboBox(String actionCommand, ActionListener listener, String... items) { JComboBox box = new JComboBox(); box.setEditable(false); for (String item : items) { box.addItem(item); } if (listener != null) { box.addActionListener(listener); box.setActionCommand(actionCommand); } return box; } }