debug Posted April 27, 2016 Share Posted April 27, 2016 // Create a select box for tree options JComboBox<String> treeSelector = new JComboBox<>(new String[]{"Tree", "Oak"}); // Add an action listener, to listen for user's selections, assign to a variable called selectedTree on selection. treeSelector.addActionListener(e -> selectedTree = treeSelector.getSelectedItem().toString()); I was using this code, but if I choose 'Tree' the client crashes, well, the CPU goes to 100% and I have to force quit, but if I choose 'Oak' then it works perfectly fine. I added another option in front of 'Tree' and now 'Tree' works in second position but the 'Oak' options is now causing the problem. Quote Link to comment Share on other sites More sharing options...
Token Posted April 27, 2016 Share Posted April 27, 2016 Open your logger when running the script and read the error it prints Quote Link to comment Share on other sites More sharing options...
debug Posted April 27, 2016 Author Share Posted April 27, 2016 Open your logger when running the script and read the error it prints Quote Link to comment Share on other sites More sharing options...
Token Posted April 27, 2016 Share Posted April 27, 2016 So line 56 in MainHandler.java is treeSelector.addActionListener(e -> selectedTree = treeSelector.getSelectedItem().toString()); ? Quote Link to comment Share on other sites More sharing options...
Explv Posted April 27, 2016 Share Posted April 27, 2016 (edited) // Create a select box for tree options JComboBox<String> treeSelector = new JComboBox<>(new String[]{"Tree", "Oak"}); // Add an action listener, to listen for user's selections, assign to a variable called selectedTree on selection. treeSelector.addActionListener(e -> selectedTree = treeSelector.getSelectedItem().toString()); I was using this code, but if I choose 'Tree' the client crashes, well, the CPU goes to 100% and I have to force quit, but if I choose 'Oak' then it works perfectly fine. I added another option in front of 'Tree' and now 'Tree' works in second position but the 'Oak' options is now causing the problem. Probably something else in your code. You should really learn what a NullPointerException is though... Edited April 27, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
debug Posted April 27, 2016 Author Share Posted April 27, 2016 So line 56 in MainHandler.java is treeSelector.addActionListener(e -> selectedTree = treeSelector.getSelectedItem().toString()); ? Line 56: status = state.toString(); That other is on line 163. Quote Link to comment Share on other sites More sharing options...
Explv Posted April 27, 2016 Share Posted April 27, 2016 Line 56: status = state.toString(); That other is on line 163. Well that is where your error is then.. Not the GUI. Pls learn how 2 debug pls pls Quote Link to comment Share on other sites More sharing options...
Token Posted April 27, 2016 Share Posted April 27, 2016 Line 56: status = state.toString(); That other is on line 163. You might want to post the whole code as what you posted does not raise any exception Your state variable is definately null though. Quote Link to comment Share on other sites More sharing options...
Explv Posted April 27, 2016 Share Posted April 27, 2016 Line 56: status = state.toString(); That other is on line 163. You probably haven't initialised 'state' Programming 101 pls pls Quote Link to comment Share on other sites More sharing options...
debug Posted April 27, 2016 Author Share Posted April 27, 2016 You probably haven't initialised 'state' Programming 101 pls pls http://pastebin.com/khgk46f9 Quote Link to comment Share on other sites More sharing options...
Explv Posted April 27, 2016 Share Posted April 27, 2016 (edited) http://pastebin.com/khgk46f9 Edited from original comment. Pls learn Java. Why are you doing this in onLoop ?: switch (state) { case CHOP: new Chop(this); break; case DROP: new Drop(this); break; case IN_COMBAT: new InCombat(this); default: break; } Edited April 27, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
debug Posted April 27, 2016 Author Share Posted April 27, 2016 Thank I managed to get it working now. Quote Link to comment Share on other sites More sharing options...
Explv Posted April 27, 2016 Share Posted April 27, 2016 Edited from original comment. Pls learn Java. Why are you doing this in onLoop ?: switch (state) { case CHOP: new Chop(this); break; case DROP: new Drop(this); break; case IN_COMBAT: new InCombat(this); default: break; } Thank I managed to get it working now. It might work but you are still doing a lot of things incorrectly Quote Link to comment Share on other sites More sharing options...
debug Posted April 27, 2016 Author Share Posted April 27, 2016 It might work but you are still doing a lot of things incorrectly Isn't it suppose to be in OnLoop()? Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted April 27, 2016 Share Posted April 27, 2016 Isn't it suppose to be in OnLoop()? You are creating new instances of those actions every loop ... Should only create one instance of it, best way to do this is in the onStart() method.. After that you can actually run those instances int he onLoop Quote Link to comment Share on other sites More sharing options...