private StaticPanel createStaticTextPanel(PrimitiveForm primitiveForm, DOTProperty property) { StaticPanel theTextPanel = createStaticComboBoxPanel( primitiveForm, property, "Text: ", DOTPointPainter.STATIC_TEXT_ITEMS); final JComboBox theComboBox = theTextPanel.getComboBox(); if (theComboBox == null) { return theTextPanel; } ItemListener comboBoxItemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (theComboBox.getSelectedIndex() == DOTPointPainter.STATIC_TEXT_ITEMS.length - 1) { theComboBox.setEditable(true); } else { theComboBox.setEditable(false); } } } }; theComboBox.addItemListener(comboBoxItemListener); ActionListener editorActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { final int length = DOTPointPainter.STATIC_TEXT_ITEMS.length; final int index = length - 1; final ComboBoxEditor editor = theComboBox.getEditor(); String editedItem = (String) editor.getItem(); theComboBox.insertItemAt(editedItem, index); final DefaultComboBoxModel model = (DefaultComboBoxModel) theComboBox.getModel(); if (model.getSize() > length) { // Sieht komisch aus, aber der direkte Weg ging nicht. model.removeElementAt(length); } } }; theComboBox.getEditor().addActionListener(editorActionListener); return theTextPanel; }