@Override public void updateUI() { super.updateUI(); JComboBox comboBox = getComboBox(); String text = getParameter().getValueAsText(); JTextComponent textComp = getTextComponent(); if (text != null && !text.equals(textComp.getText())) { if (textComp != null) { if (!textComp.getText().equals(text)) { textComp.setText(text); } } Object selItem = comboBox.getSelectedItem(); if (selItem == null || !selItem.equals(text)) { comboBox.setSelectedItem(text); } } if (comboBox.isEnabled() != isEnabled()) { comboBox.setEnabled(isEnabled()); } }
@Override protected void initUI() { setDefaultLabelComponent(true); _comboBox = new JComboBox(); nameEditorComponent(_comboBox); // Configure combo box if (getParameter().getProperties().getDescription() != null) { _comboBox.setToolTipText(getParameter().getProperties().getDescription()); } if (getParameter().getProperties().getValueSet() != null) { _comboBox.setModel(new DefaultComboBoxModel(getParameter().getProperties().getValueSet())); } _comboBox.setEnabled(!getParameter().getProperties().isReadOnly()); _comboBox.setEditable(!getParameter().getProperties().isValueSetBound()); JTextComponent textComp = getTextComponent(); if (textComp != null) { textComp.setInputVerifier(getDefaultInputVerifier()); } _comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { updateParameter(); } }); java.awt.Font font = _comboBox.getFont(); if (font != null) { _comboBox.setFont(new java.awt.Font(font.getName(), Font.PLAIN, font.getSize())); } }
private void updateParameter() { JTextComponent textComp = getTextComponent(); if (textComp != null && getComboBox().isEditable()) { setParameterValue(textComp); } else { Object newValue = getComboBox().getSelectedItem(); getParameter().setValueAsText(newValue != null ? newValue.toString() : "", getExceptionHandler()); } } }
String[] valueSet = getParameter().getProperties().getValueSet(); if (valueSet != null) { for (int i = 0; i < valueSet.length; i++) { setEnabled(!getParameter().getProperties().isReadOnly()); jComboBox.setEditable(!getParameter().getProperties().isValueSetBound()); jComboBox.setSelectedItem(getParameter().getValueAsText());