Renegeade Posted December 31, 2014 Share Posted December 31, 2014 Hello, I'm working on a script for OSBot, but I've run into a bit of an issue that's driving me crazy I try to open up a JFrame in my onStart(), and I always get the error "Error in script onStart()". That would be fine and dandy if I got some kind of exception in the console, but I'm not, so I have no idea why the error is occurring. By printing out things via the logger, I've determined that the issue is occurring in a constructor of mine. However this constructor still causes an issue even if it's blank. public void onStart() { this.getBot().getLogger().debug("Opening up JFrame..."); config = new StartConfig(this); window = new JFrame("Start PestControlSucks"); window.setSize(570, 330); window.add(config.getControlPane()); window.pack(); window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation(dim.width / 2 - window.getWidth() / 2, dim.height / 2 - window.getHeight() / 2); window.setVisible(true); this.getBot().getLogger().debug("JFrame opened, waiting on user input!"); } Based on previous debug messages I left, it never gets past new StartConfig public StartConfig(PestControl instance) { this.instance = instance; try { instance.getBot().getLogger().debug("Setting up radio group"); radioGroup.add(radioPurchaseXP); radioGroup.add(radioPurchaseVoid); radioGroup.add(radioLogOut); defaultColor = panelAttack.getBackground(); instance.getBot().getLogger().debug("Starting to load icons"); // Experience rewards labelAttack.setIcon(loadImageIcon("attack")); labelStrength.setIcon(loadImageIcon("strength")); labelDefence.setIcon(loadImageIcon("defence")); labelRange.setIcon(loadImageIcon("range")); labelMagic.setIcon(loadImageIcon("magic")); labelHitpoints.setIcon(loadImageIcon("hitpoints")); labelPrayer.setIcon(loadImageIcon("prayer")); // Void rewards labelVoidMace.setIcon(loadImageIcon("void_mace")); labelVoidBottom.setIcon(loadImageIcon("void_bottom")); labelVoidTop.setIcon(loadImageIcon("void_top")); labelVoidMelee.setIcon(loadImageIcon("void_melee")); labelVoidRange.setIcon(loadImageIcon("void_range")); labelVoidMage.setIcon(loadImageIcon("void_mage")); labelVoidGloves.setIcon(loadImageIcon("void_gloves")); buttonStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { StartConfig.this.instance.reallyStart(); } }); } catch (Exception ex) { instance.getBot().getLogger().debug("Error: " + ex.toString()); instance.getBot().getLogger().error(this, ex); ex.printStackTrace(); } } However, it never even gets to "Setting up radio group" What's going on? Is there any way to enable stacktraces for onStart() Thanks! Link to comment Share on other sites More sharing options...
Dreamliner Posted December 31, 2014 Share Posted December 31, 2014 Use WindowBuilder Link to comment Share on other sites More sharing options...
Joseph Posted December 31, 2014 Share Posted December 31, 2014 (edited) you can remove everything from on start. Closely add in each line and see which line give you the error. Edited December 31, 2014 by josedpay Link to comment Share on other sites More sharing options...
Novak Posted December 31, 2014 Share Posted December 31, 2014 (edited) is startconfig in your main class? if so why are you passing an instance of PestControl(which i assume is your main class) Edited December 31, 2014 by Novak Link to comment Share on other sites More sharing options...
Renegeade Posted December 31, 2014 Author Share Posted December 31, 2014 is startconfig in your main class? if so why are you passing an instance of PestControl(which i assume is your main class) No, PestControl is the main class. I designed the GUI with Intellij's Swing designer. StartConfig contains the control JPanel, which I add into a JFrame you can remove everything from on start. Closely add in each line and see which line give you the error. I have already pinpointed the constructor for StartConfig as the error, the rest of onStart works properly Link to comment Share on other sites More sharing options...
Joseph Posted January 1, 2015 Share Posted January 1, 2015 keep working on it and fix the problem Link to comment Share on other sites More sharing options...
Renegeade Posted January 1, 2015 Author Share Posted January 1, 2015 I ended up using a hacky solution to get the stacktrace from the bot thread. It looks like the NPE was getting thrown in a function called $$$setupUI$$$(), which is automatically generated by Intellij for the Swing designer. I had no clue as to why it wasn't working, so I ended up deleting the form and recreating it, and it worked. 1 Link to comment Share on other sites More sharing options...
Joseph Posted January 1, 2015 Share Posted January 1, 2015 Good shit I do the same thing when shit like that happens to me Link to comment Share on other sites More sharing options...