This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Hi, I tried out your example http://platform.netbeans.org/tutorials/60/nbm-property-editors.html Unfortunately it doesn't work. The editor does not store the value. I applied some minor changes, but I'm not sure, if this is Netbeans conformant. import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyEditor; import java.beans.PropertyEditorSupport; import java.lang.reflect.InvocationTargetException; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.KeyStroke; import org.openide.explorer.propertysheet.ExPropertyEditor; import org.openide.explorer.propertysheet.InplaceEditor; import org.openide.explorer.propertysheet.PropertyEnv; import org.openide.explorer.propertysheet.PropertyModel; import org.openide.util.Exceptions; /** * * @author thorsten */ public class RahmenstilPropertyEditor extends PropertyEditorSupport implements ExPropertyEditor, InplaceEditor.Factory { private static final String[] values = new String[]{ "none", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"}; @Override public String getAsText() { return getValue().toString(); } @Override public boolean supportsCustomEditor() { return false; } @Override public void setAsText(String text) throws IllegalArgumentException { ed.cb.setSelectedItem(text); setValue(text); } public void attachEnv(PropertyEnv pe) { pe.registerInplaceEditorFactory(this); } private Inplace ed = new Inplace(); public InplaceEditor getInplaceEditor() { if (ed == null) { ed = new Inplace(); } return ed; } private class Inplace implements InplaceEditor, ActionListener { private PropertyEditor editor = null; private PropertyEnv propertyEnv = null; public JComboBox cb = new JComboBox(values); private PropertyModel model = null; public void connect(PropertyEditor propertyEditor, PropertyEnv env) { editor = propertyEditor; propertyEnv = env; reset(); cb.addActionListener(this); } public JComponent getComponent() { return cb; } public void clear() { //avoid memory leaks: editor = null; model = null; cb.removeActionListener(this); } public Object getValue() { try { return model.getValue(); } catch (InvocationTargetException ex) { Exceptions.printStackTrace(ex); return null; } } public void setValue(Object object) { cb.setSelectedItem(object); try { model.setValue(object); } catch (InvocationTargetException ex) { Exceptions.printStackTrace(ex); } } public boolean supportsTextEntry() { return false; } public void reset() { cb.setSelectedIndex(0); } public KeyStroke[] getKeyStrokes() { return new KeyStroke[0]; } public PropertyEditor getPropertyEditor() { return editor; } public PropertyModel getPropertyModel() { return model; } public void setPropertyModel(PropertyModel propertyModel) { model = propertyModel; } public boolean isKnownComponent(Component component) { return component == cb || cb.isAncestorOf(component); } public void addActionListener(ActionListener actionListener) { } public void removeActionListener(ActionListener actionListener) { } public void actionPerformed(ActionEvent e) { try { model.setValue(cb.getSelectedItem()); } catch (InvocationTargetException ex) { Exceptions.printStackTrace(ex); } } } } Best Regards Thorsten Kiefer
Assigning to Geertjan for evaluation. Geertjan, can you please take a look?
You're by no means the first person to have followed the tutorial. Anyway, reassigning this to Tim Boudreau, who wrote the tutorial.
And, by the way, here is the current version of the tutorial: http://platform.netbeans.org/tutorials/nbm-property-editors.html
Uy... I *am* the default assignee for javacard...