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();
}
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);
}
}
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" + "학기");
}
}
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));
}
}
}
}
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);
}
Aggregations