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.
Let's say we have two JComboBox (1 and 2) and jComboBox1's got already a set of String elements. In the stateChanged methof (i dont remember the exact name of the listenner method), those lines will create an Null Exception: jComboBox1.removeAllItems(); jComboBox2.addItem(jComboBox1.getSelectedItem().toString()); However, i fixed it by typing: jComboBox1.removeAllItems(); jComboBox2.addItem((String)jComboBox1.getSelectedItem()); But, normally, toString() converts in a String format...!
> jComboBox1.removeAllItems(); > jComboBox2.addItem(jComboBox1.getSelectedItem().toString()); This code snippet has no sense. You remove all items from jComboBox1 and then (when there are no items there) you ask for the selected item of jComboBox1. Not surprisingly the selected item (i.e., jComboBox1.getSelectedItem()) is _null_ in such case. Therefore, NullPointerException is thrown when you attempt to invoke toString() on the returned value. Note that besides having no sense this code snippet has nothing to do with NetBeans IDE. It is a problem in your code => I am closing this issue as invalid.