Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • GUI Threading problems


    shiftyayef
     Share

    Recommended Posts

    Hi,

    When trying to create a GUI for my script and initialise it in the "onStart" method, I am getting a persistent error:

    The first one it throws is:

    [ERROR] Swing threading error:: java.lang.Exception: State tracking must be done on Event Dispatch Thread. Try wrapping your method in SwingUtilities#invokeLater

    Followed by:

    13:35:03: [ERROR] java.awt.IllegalComponentStateException: contentPane cannot be set to null.

     

    This is what I have wrapped in invokeLater, but it still throws the exception (GUI extends JFrame).

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            GUI gui = new GUI("Shifty NMZ");
        }
    });

    My GUI is built using intellij's GUI designer forms - if I try and make a basic JFrame with only Swing, it doesn't throw an exception, so I'm a bit lost.

     

    Does anyone know what the cause/solution could be?


    Thank you

     

    UPDATE:

    My problem turned out to be related to the gradle configuration I was using to build my scripts. After creating a new project using Maven, creating an instance of the GUI inside SwingUtilities.invokeLater() worked fine. Leaving the rest of the post up in case anyone has similar issues in future.

    Edited by shiftyayef
    RESOLVED
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.