Remove Item from JList throws NullPointerException?

Your change "fixed" your problem because getSelectedValue().toString() will throw a NPE if there is no selection, whereas (String)getSelectedValue() will evaluate to null if there is no selection. But, if you ever put things in your list that aren't String s, then you'll get ClassCastException s when you try to cast the selected value to a String So, this may have solved your current problem, but it's not a solution really.

Your change "fixed" your problem because getSelectedValue().toString() will throw a NPE if there is no selection, whereas (String)getSelectedValue() will evaluate to null if there is no selection. But, if you ever put things in your list that aren't Strings, then you'll get ClassCastExceptions when you try to cast the selected value to a String. So, this may have solved your current problem, but it's not a solution really.

I would just do this: private void theListValueChanged(ListSelectionEvent e) { final Object selectedValue = theList. GetSelectedValue(); if ( selectedValue! = null ) { txtCameraName.

SetText( selectedValue.toString() ); } else { // Clear the text since there's no selection txtCameraName. SetText( null ); } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions