Search in sources :

Example 16 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project pcgen by PCGen.

the class NameGenPanel method loadDropdowns.

private void loadDropdowns() {
    //	This method now just loads the category dropdown from the list of 
    //	category names
    Vector<String> cats = this.getCategoryNames();
    cbCategory.setModel(new DefaultComboBoxModel(cats));
    this.loadGenderDD();
    this.loadCatalogDD();
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 17 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project pcgen by PCGen.

the class NameGenPanel method loadGenderDD.

//	Load the gender drop dowd
private void loadGenderDD() {
    List<String> genders = getGenderCategoryNames();
    Vector<String> selectable = new Vector<>();
    String gender = (String) cbSex.getSelectedItem();
    //	Get the selected category name
    String category = (String) cbCategory.getSelectedItem();
    //	Get the set of rules for selected category
    List<RuleSet> categoryRules = categories.get(category);
    //	loop through the available genders
    for (String genderString : genders) {
        //	Get the list of rules for the current gender
        List<RuleSet> genderRules = categories.get("Sex: " + genderString);
        //	now loop through all the rules from the selected category
        for (RuleSet categoryRule : categoryRules) {
            //	we can stop processing the list once we find a match
            if (genderRules.contains(categoryRule)) {
                selectable.add(genderString);
                break;
            }
        }
    }
    //	Sort the genders
    Collections.sort(selectable);
    //	Create a new model for the combobox and set it
    cbSex.setModel(new DefaultComboBoxModel(selectable));
    if (gender != null && selectable.contains(gender)) {
        cbSex.setSelectedItem(gender);
    }
}
Also used : RuleSet(pcgen.core.doomsdaybook.RuleSet) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Vector(java.util.Vector)

Example 18 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project SE2017_4_tuna by SE-admin.

the class MainFrame method InitComboBox.

public static void InitComboBox() {
    DefaultComboBoxModel<String> FindModel = (DefaultComboBoxModel<String>) yearsemeList.getModel();
    FindModel.removeAllElements();
    ArrayList<String> arrList = new ArrayList<String>();
    for (int i = 0; i < GlobalVal.aGrade.size(); i++) {
        arrList.add(GlobalVal.aGrade.get(i).getyear() + "년도 " + GlobalVal.aGrade.get(i).getsemester() + "학기");
    }
    HashSet<String> hs = new HashSet<String>();
    hs.addAll(arrList);
    arrList.clear();
    arrList.addAll(hs);
    if (arrList.size() > 0) {
        for (int i = 0; i < arrList.size(); i++) {
            FindModel.addElement(arrList.get(i));
        }
    } else {
        java.util.Calendar cal = java.util.Calendar.getInstance();
        FindModel.addElement(Integer.toString(cal.get(Calendar.YEAR)) + "년도 " + "1" + "학기");
    }
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) HashSet(java.util.HashSet)

Example 19 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project ACS by ACS-Community.

the class DateTimeSelector method ratioDayCB.

/**
	 * The days displayed by {@link #dayCB} depends on the month
	 */
private void ratioDayCB() {
    int selectedMonth = (Integer) monthCB.getSelectedItem();
    int selectedYear = (Integer) yearCB.getSelectedItem();
    int maxDays;
    switch(selectedMonth) {
        case 2:
            {
                // Feb
                maxDays = (selectedYear % 4 == 0) ? 29 : 28;
                break;
            }
        // Mar
        case 3:
        // Apr
        case 4:
        //Jun
        case 6:
        // Sep
        case 9:
        case 11:
            {
                //Nov 
                maxDays = 30;
                break;
            }
        default:
            {
                maxDays = 31;
            }
    }
    DefaultComboBoxModel cbModel = (DefaultComboBoxModel) dayCB.getModel();
    for (int d = 29; d <= 31; d++) {
        if (d <= maxDays) {
            // This day must be present for the selected month
            if (cbModel.getIndexOf(Integer.valueOf(d)) == -1) {
                dayCB.addItem(Integer.valueOf(d));
            }
        } else {
            // This day must be removed for the selected month
            if (cbModel.getIndexOf(Integer.valueOf(d)) != -1) {
                dayCB.removeItem(Integer.valueOf(d));
            }
        }
    }
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 20 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project adempiere by adempiere.

the class PreviewPanel method setLFSelection.

/**
	 *  Update the look list and theme list to show the current selection
	 */
private void setLFSelection() {
    m_setting = true;
    //  Search for PLAF
    ValueNamePair plaf = null;
    LookAndFeel lookFeel = UIManager.getLookAndFeel();
    String look = lookFeel.getClass().getName();
    for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) {
        ValueNamePair vp = AdempierePLAF.getPLAFs()[i];
        if (vp.getValue().equals(look)) {
            plaf = vp;
            break;
        }
    }
    if (plaf != null)
        lookList.setSelectedValue(plaf, true);
    //  Search for Theme
    MetalTheme metalTheme = null;
    ValueNamePair theme = null;
    boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
    themeList.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes()));
    if (metal) {
        theme = null;
        AppContext context = AppContext.getAppContext();
        metalTheme = (MetalTheme) context.get("currentMetalTheme");
        if (metalTheme != null) {
            String lookTheme = metalTheme.getName();
            for (int i = 0; i < AdempierePLAF.getThemes().length; i++) {
                ValueNamePair vp = AdempierePLAF.getThemes()[i];
                if (vp.getName().equals(lookTheme)) {
                    theme = vp;
                    break;
                }
            }
        }
        if (theme != null)
            themeList.setSelectedValue(theme, true);
    }
    m_setting = false;
    log.info(lookFeel + " - " + metalTheme);
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) AppContext(sun.awt.AppContext) ValueNamePair(org.compiere.util.ValueNamePair) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Aggregations

DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)119 JComboBox (javax.swing.JComboBox)22 JPanel (javax.swing.JPanel)21 JLabel (javax.swing.JLabel)17 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 JButton (javax.swing.JButton)15 Insets (java.awt.Insets)14 GridBagConstraints (java.awt.GridBagConstraints)13 GridBagLayout (java.awt.GridBagLayout)12 Dimension (java.awt.Dimension)11 JTextField (javax.swing.JTextField)11 JCheckBox (javax.swing.JCheckBox)10 JScrollPane (javax.swing.JScrollPane)10 ArrayList (java.util.ArrayList)9 Vector (java.util.Vector)9 JList (javax.swing.JList)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 BorderLayout (java.awt.BorderLayout)8 ItemEvent (java.awt.event.ItemEvent)8