Java JComboBox makeJComboBox(ResourceBundle resource, String panelName, String keyword)

Here you can find the source of makeJComboBox(ResourceBundle resource, String panelName, String keyword)

Description

make J Combo Box

License

Open Source License

Declaration

public static JComboBox<String> makeJComboBox(ResourceBundle resource, String panelName, String keyword) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import javax.swing.JComboBox;

public class Main {
    public static JComboBox<String> makeJComboBox(ResourceBundle resource, String panelName, String keyword) {
        String value = null;/*from  ww  w . j av  a2  s . c  o m*/
        try {
            value = resource.getString(panelName + "_COMBOBOX_" + keyword + "_DEFAULT");
        } catch (MissingResourceException e) {
        }
        JComboBox<String> jcb = new JComboBox<>();
        String val = null;
        int ii = 0;
        do {
            try {
                val = resource.getString(panelName + "_COMBOBOX_" + keyword + "_VALUE_" + ii);
                if (val != null) {
                    jcb.addItem(val);
                }
                ++ii;
            } catch (MissingResourceException e) {
                val = null;
            }
        } while (val != null);

        if (value != null)
            jcb.setSelectedItem(value);
        return jcb;
    }
}

Related

  1. isJComboBoxNotEmpty(javax.swing.JComboBox combo)
  2. largeThan(javax.swing.JComboBox input, double x)
  3. loadComboBox(JComboBox combo, List list)
  4. loadEnum(JComboBox combo, Class c, boolean removeAll)
  5. loadPrefs(Preferences prefs, String prefKey, JComboBox combo)
  6. makeSquare(JComboBox... comboBoxes)
  7. newCombo(int chars)
  8. prepareComboBox(JComboBox comboBox, Dimension size, int min, int max, int[] list)
  9. registerBrowseButtonListener(final JComboBox comboBox, final JButton button, final boolean chooseFile, final boolean isOpen, final FileFilter fileFilter, final File initialDirectory)