Java Examples for javax.swing.DefaultComboBoxModel

The following java examples will help you to understand the usage of javax.swing.DefaultComboBoxModel. These source code samples are taken from different open source projects.

Example 1
Project: ProjectLibre-master  File: NewBaseCalendarDialog.java View source code
protected boolean bind(boolean get) {
    CalendarService service = CalendarService.getInstance();
    if (get) {
        ComboBoxModel calModel = new DefaultComboBoxModel(service.getBaseCalendars().toArray());
        calendarToCopy.setModel(calModel);
    } else {
        WorkingCalendar toCopy;
        if (makeACopy.isSelected())
            toCopy = (WorkingCalendar) calendarToCopy.getSelectedItem();
        else
            toCopy = CalendarService.getInstance().getDefaultInstance();
        newCalendar = CalendarService.getInstance().makeScratchCopy(toCopy);
        newCalendar.setName(name.getText());
        service.add(newCalendar);
    }
    return super.bind(get);
}
Example 2
Project: statalign-master  File: DataButtonGroup.java View source code
public void updateGUI() {
    int n = PPfoldMain.datainfo.size();
    String[] datalabels = new String[n];
    for (int i = 0; i < n; i++) {
        String datatype = "data";
        DataInfo datainfo = PPfoldMain.datainfo.get(i);
        if (datainfo.getType() == 0) {
            datatype = "(Probing data)";
        } else if (datainfo.getType() == 1) {
            datatype = "(Probability data)";
        } else {
            datatype = "(Constraint data)";
        }
        datalabels[i] = new String(PPfoldMain.datainfo.get(i).getiD() + " " + datatype);
    }
    final DefaultComboBoxModel model = new DefaultComboBoxModel(datalabels);
    chooser.setModel(model);
    chooser.setSelectedIndex(n - 1);
    chooser.updateUI();
}
Example 3
Project: eclipselink.runtime-master  File: CompositeIconUITest.java View source code
private void initializeModels() {
    this.entryListModel = new DefaultListModel();
    this.orientationModel = new DefaultComboBoxModel(ORIENTATION_CHOICES);
    this.orientationModel.setSelectedItem(ORIENTATION_HORIZONTAL);
    this.alignmentModel = new DefaultComboBoxModel(HORIZONTAL_ALIGNMENT_CHOICES);
    this.alignmentModel.setSelectedItem(ALIGNMENT_CENTER);
    this.orientationModel.addListDataListener(this.buildOrientationListener());
    this.redXModel = this.buildIconSizeModel();
    this.redYModel = this.buildIconSizeModel();
    this.gap1SizeModel = this.buildGapSizeModel();
    this.greenXModel = this.buildIconSizeModel();
    this.greenYModel = this.buildIconSizeModel();
    this.gap2SizeModel = this.buildGapSizeModel();
    this.blueXModel = this.buildIconSizeModel();
    this.blueYModel = this.buildIconSizeModel();
}
Example 4
Project: snap-desktop-master  File: TimeSeriesValidator.java View source code
@Override
public void adaptTo(Object timeSeriesKey, AxisMapping axisMapping) {
    if (timeSeriesExpressionsMap.containsKey(timeSeriesKey)) {
        currentExpressionMap = timeSeriesExpressionsMap.get(timeSeriesKey);
    } else {
        currentExpressionMap = new HashMap<>();
        timeSeriesExpressionsMap.put(timeSeriesKey, currentExpressionMap);
    }
    qualifiedSourceNames = extractQualifiedSourceNames(axisMapping);
    namespace = new DefaultNamespace();
    for (String qualifiedSourceName : qualifiedSourceNames) {
        namespace.registerSymbol(SymbolFactory.createVariable(qualifiedSourceName, 0.0));
    }
    if (qualifiedSourceNames.size() > 0 && hasUI) {
        expressionTextField.setEnabled(true);
        sourceNamesDropDown.setEnabled(true);
        sourceNamesDropDown.setModel(new DefaultComboBoxModel<>(getSourceNames()));
        final String expression = getExpressionFor(getSelectedSourceName());
        expressionTextField.setText(expression == null ? "" : expression);
    }
}
Example 5
Project: freemind-mmx-master  File: AssignAttributeDialog.java View source code
private void attributesChanged() {
    AttributeRegistry attributes = mapView.getModel().getRegistry().getAttributes();
    ComboBoxModel names = attributes.getComboBoxModel();
    attributeNames.setModel(new ClonedComboBoxModel(names));
    attributeNames.setEditable(!attributes.isRestricted());
    replacingAttributeNames.setModel(new ClonedComboBoxModel(names));
    replacingAttributeNames.setEditable(!attributes.isRestricted());
    if (attributes.size() > 0) {
        Object first = names.getElementAt(0);
        attributeNames.setSelectedItem(first);
        replacingAttributeNames.setSelectedItem(first);
        selectedAttributeChanged(attributeNames.getSelectedItem(), attributeValues);
        selectedAttributeChanged(replacingAttributeNames.getSelectedItem(), replacingAttributeValues);
    } else {
        attributeValues.setModel(new DefaultComboBoxModel());
        attributeValues.setEditable(false);
        replacingAttributeValues.setModel(new DefaultComboBoxModel());
        replacingAttributeValues.setEditable(false);
    }
}
Example 6
Project: NemoVelo-master  File: TerminalReturnBikesPanel.java View source code
private void initialize(int bikeIndex) {
    GridBagConstraints gbc;
    this.bikeIndex = bikeIndex;
    GridBagLayout gbl = new GridBagLayout();
    {
        gbl.columnWidths = new int[] { 0, 0, 0 };
        gbl.rowHeights = new int[] { 0, 0 };
        gbl.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
        gbl.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
    }
    setLayout(gbl);
    JLabel lblBikeNumber = new JLabel("Vélo " + (this.bikeIndex + 1) + ", N° de série : ");
    //Position
    {
        gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.VERTICAL;
        gbc.insets = new Insets(0, TerminalMainFrame.HORIZONTAL_GAP, 0, TerminalMainFrame.HORIZONTAL_GAP);
        gbc.anchor = GridBagConstraints.EAST;
        gbc.gridx = 0;
        gbc.gridy = 0;
    }
    this.add(lblBikeNumber, gbc);
    this.comboBikeSerialNumber = new JComboBox();
    {
        lblBikeNumber.setLabelFor(this.comboBikeSerialNumber);
        this.comboBikeSerialNumber.setModel(new DefaultComboBoxModel(rentedBikeSerialNumbers));
        //Position
        {
            gbc = new GridBagConstraints();
            gbc.fill = GridBagConstraints.BOTH;
            gbc.gridx = 1;
            gbc.gridy = 0;
        }
    }
    this.add(comboBikeSerialNumber, gbc);
}
Example 7
Project: geotoolkit-master  File: SampleDimensionPanel.java View source code
/**
     * Sets the sample dimensions to make available in this panel. This method
     * will initially show the first sample dimension found in the list, if any.
     *
     * @param bands The sample dimensions to show, or [email protected] null} if none.
     */
public void setSampleDimensions(final List<GridSampleDimension> bands) {
    final Locale locale = getLocale();
    final Vocabulary resources = Vocabulary.getResources(locale);
    final DefaultComboBoxModel<BandName> nameList = (DefaultComboBoxModel<BandName>) nameField.getModel();
    nameList.removeAllElements();
    units = null;
    records = null;
    sampleDimensions = null;
    if (!isNullOrEmpty(bands)) {
        final int n = bands.size();
        sampleDimensions = bands.toArray(new GridSampleDimension[n]);
        records = new CategoryRecord[n][];
        units = new Unit<?>[n];
        for (int i = 0; i < n; i++) {
            final GridSampleDimension band = sampleDimensions[i];
            units[i] = band.getUnits();
            final InternationalString desc = band.getDescription();
            String name = null;
            if (desc != null) {
                name = desc.toString(locale);
            }
            if (name == null) {
                name = resources.getString(Vocabulary.Keys.Band_1, i + 1);
            }
            nameList.addElement(new BandName(i, name));
        }
    }
}
Example 8
Project: Desktop-master  File: FilterConditionEditor.java View source code
public ASelectableCondition getCondition() {
    ASelectableCondition newCond;
    Object value;
    if (values.isEditable()) {
        value = values.getEditor().getItem();
    } else {
        value = values.getSelectedItem();
    }
    if (value == null) {
        value = "";
    }
    final NamedObject simpleCond = (NamedObject) elementaryConditions.getSelectedItem();
    final boolean matchCase = caseSensitive.isSelected();
    final boolean matchApproximately = approximateMatching.isSelected();
    ResourceController.getResourceController().setProperty(PROPERTY_FILTER_MATCH_CASE, matchCase);
    final Object selectedItem = filteredPropertiesComponent.getSelectedItem();
    newCond = filterController.getConditionFactory().createCondition(selectedItem, simpleCond, value, matchCase, matchApproximately);
    if (values.isEditable()) {
        if (!value.equals("")) {
            DefaultComboBoxModel list = (DefaultComboBoxModel) values.getModel();
            int indexOfValue = list.getIndexOf(value);
            if (indexOfValue > 0)
                list.removeElementAt(indexOfValue);
            if (indexOfValue == -1 || list.getIndexOf(value) != indexOfValue) {
                values.insertItemAt(value, 0);
                values.setSelectedIndex(0);
            } else if (indexOfValue != -1) {
                values.setSelectedIndex(indexOfValue);
            }
            if (values.getItemCount() >= 10) {
                values.removeItemAt(9);
            }
        }
    }
    return newCond;
}
Example 9
Project: GdxStudio-master  File: EffectUtil.java View source code
/** Returns a value that represents a fixed number of options. All options are strings.
	 * @param options The first array has an entry for each option. Each entry is either a String[1] that is both the display value
	 *           and actual value, or a String[2] whose first element is the display value and second element is the actual value. */
public static Value optionValue(String name, final String currentValue, final String[][] options, final String description) {
    return new DefaultValue(name, currentValue.toString()) {

        public void showDialog() {
            int selectedIndex = -1;
            DefaultComboBoxModel model = new DefaultComboBoxModel();
            for (int i = 0; i < options.length; i++) {
                model.addElement(options[i][0]);
                if (getValue(i).equals(currentValue))
                    selectedIndex = i;
            }
            JComboBox comboBox = new JComboBox(model);
            comboBox.setSelectedIndex(selectedIndex);
            if (showValueDialog(comboBox, description))
                value = getValue(comboBox.getSelectedIndex());
        }

        private String getValue(int i) {
            if (options[i].length == 1)
                return options[i][0];
            return options[i][1];
        }

        public String toString() {
            for (int i = 0; i < options.length; i++) if (getValue(i).equals(value))
                return options[i][0].toString();
            return "";
        }

        public Object getObject() {
            return value;
        }
    };
}
Example 10
Project: pcgen-master  File: DefaultsPanel.java View source code
/* (non-Javadoc)
	 * @see pcgen.gui2.prefs.PreferencesPanel#initPreferences()
	 */
@Override
public void applyOptionValuesToControls() {
    final GameMode gameMode = SettingsHandler.getGame();
    final String xpTableName = gameMode.getDefaultXPTableName();
    List<String> xpTableNames = gameMode.getXPTableNames();
    xpTableCombo.removeAllItems();
    for (String name : xpTableNames) {
        xpTableCombo.addItem(name);
    }
    xpTableCombo.setSelectedItem(xpTableName);
    final String characterType = gameMode.getDefaultCharacterType();
    List<String> characterTypes = gameMode.getCharacterTypeList();
    characterTypeCombo.removeAllItems();
    for (String name : characterTypes) {
        characterTypeCombo.addItem(name);
    }
    characterTypeCombo.setSelectedItem(characterType);
    final String previewSheet = UIPropertyContext.getInstance().initProperty(DEFAULT_PREVIEW_SHEET_KEY + gameMode, gameMode.getDefaultPreviewSheet());
    String previewDir = ConfigurationSettings.getPreviewDir();
    File sheetDir = new File(previewDir, gameMode.getCharSheetDir());
    if (sheetDir.exists() && sheetDir.isDirectory()) {
        String[] files = sheetDir.list(( path,  filename) -> {
            File file = new File(path, filename);
            return file.isFile() && !file.isHidden();
        });
        //String[] files = sheetDir.list();
        previewSheetCombo.removeAllItems();
        previewSheetCombo.setModel(new DefaultComboBoxModel(files));
        previewSheetCombo.sortItems();
        previewSheetCombo.setSelectedItem(previewSheet);
    }
}