Lol_marcus Posted June 6, 2020 Share Posted June 6, 2020 (edited) Basically, if I add an icon to the JOptionPane, it doesn't recognize my option anymore. If I leave it without an image, it does recognize the option. It's obviously something with the code, but what is it? O_O What it does is, I let the user select the type of log they want, and then perform an action based on that. Here's a snippet: Code that works @Override public void onStart() throws InterruptedException { String userOptions[] = { "Logs", "Oak logs", "Teak logs", "Mahogany logs" }; String userChoice = "" + (String) JOptionPane.showInputDialog(null, "Choose a log type", "Log Selection Menu", JOptionPane.PLAIN_MESSAGE, null, userOptions, userOptions[1]); } Code that doesn't work @Override public void onStart() throws InterruptedException { ImageIcon icon = null; try { icon = new ImageIcon(new URL( "https://vignette.wikia.nocookie.net/2007scape/images/6/65/Demon_butler_chathead.png/revision/latest?cb=20151103211007")); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } String userOptions[] = { "Logs", "Oak logs", "Teak logs", "Mahogany logs" }; String userChoice = "" + (String) JOptionPane.showInputDialog(null, "Choose a log type", "Log Selection Menu", JOptionPane.PLAIN_MESSAGE, icon, userOptions, userOptions[1]); } Edited June 6, 2020 by Lol_marcus Quote Link to comment Share on other sites More sharing options...
Camaro Posted June 6, 2020 Share Posted June 6, 2020 Seems to work fine for me. Print userChoice to the logger at the end of onStart and see if you see the result. Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted June 6, 2020 Share Posted June 6, 2020 By not recognizing your option anymore, do you mean that it is returning a value that was not selected? Or is it that the values in the JOptionPane are not the options you are passing into it? Quote Link to comment Share on other sites More sharing options...
Lol_marcus Posted June 6, 2020 Author Share Posted June 6, 2020 (edited) It's not passing on the option to the rest of the script. I'm getting "userChoice is an invalid variable" if I try to do something like getBank().withdrawAll(userChoice); with the code that doesn't work. If I remove all the code to add my icon it works fine. The code itself works, it's just not passing the users choice for some odd reason. Edited June 6, 2020 by Lol_marcus Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted June 8, 2020 Share Posted June 8, 2020 On 6/6/2020 at 4:40 AM, Lol_marcus said: It's not passing on the option to the rest of the script. I'm getting "userChoice is an invalid variable" if I try to do something like getBank().withdrawAll(userChoice); with the code that doesn't work. If I remove all the code to add my icon it works fine. The code itself works, it's just not passing the users choice for some odd reason. If the code above is the same that you are using and you are trying to access the userChoice variable outside of the onStart() than it will show invalid variable, as you have only created that variable inside of the onStart(). Add the userChoice var to the class and set that value in the onStart(), you will than be able to use that variable. Quote Link to comment Share on other sites More sharing options...