I have been trying to figure it out for 3 days...no luck!
Anyone Please help,
leila la wrote:if (jcomboBox_LastTank.getSelectedItem() == "Blue")
Thats the line at 336
OK, and you're getting an NPE. Since "Blue" can't possibly be null, and it doesn't matter if getSelectedItem() returns a null (the expression will simply be false), the problem must be with jcomboBox_LastTank.
Your task: find out why it's null.
Also: Listen to Ulf and get rid of that '=='; he talketh sense.
Ok I shall remove the == sign, but what do i put in that place? the word "equals" or just one equal sign? If it is just one equal sign, i get an error.
leila la wrote:Ok I shall remove the == sign, but what do i put in that place? the word "equals" or just one equal sign? If it is just one equal sign, i get an error.
No, you put a call to the equals() method, which is how you should ALWAYS compare objects. ie:
if ( X.equals(Y) ) ...
PS: A little tip for you - If one of the objects is a String literal, it's often a good idea to put it first, ie:
if ( "Blue".equals(jcomboBox_LastTank.getSelectedItem()) )
if ( jcomboBox_LastTank.getSelectedItem().equals("Blue") )
because a literal can't possibly be null.