Here you can find the source of prepareComboBox(JComboBox comboBox, Dimension size, int min, int max, int[] list)
Parameter | Description |
---|---|
comboBox | reference to the control |
size | size of the control |
min | minimum value of the comboBox item |
max | maximum value of the comboBox item |
list | list of comboBox items |
@SuppressWarnings({ "rawtypes", "unchecked" }) public static void prepareComboBox(JComboBox comboBox, Dimension size, int min, int max, int[] list)
//package com.java2s; //License from project: Open Source License import java.awt.Dimension; import java.awt.Font; import java.util.List; import javax.swing.JComboBox; public class Main { private static final Font fontComboBox = new Font("arial", Font.BOLD, 12);//from ww w. j a v a 2 s. c om /** * prepares comboBox control * @param comboBox reference to the control * @param size size of the control * @param min minimum value of the comboBox item * @param max maximum value of the comboBox item * @param list list of comboBox items */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static void prepareComboBox(JComboBox comboBox, Dimension size, int min, int max, int[] list) { comboBox.setLayout(null); comboBox.setSize(size); comboBox.setFont(fontComboBox); comboBox.removeAllItems(); for (; min <= max; min++) { comboBox.addItem(min); } if (list != null) { for (int i = 0; i < list.length; i++) { comboBox.addItem(list[i]); } } } /** * prepares comboBox control * @param comboBox reference to the control * @param size size of the control * @param list list of comboBox items */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static void prepareComboBox(JComboBox comboBox, Dimension size, List<String> list) { comboBox.setLayout(null); comboBox.setSize(size); comboBox.setFont(fontComboBox); comboBox.removeAllItems(); if (list != null) { for (String item : list) { comboBox.addItem(item); } } } }