The client is offline due to RuneScape update. You may see instance errors but this is due to the update and not actual instance errors. This should be resolved soon. Join our Discord for more information.

Ask for user input at the start of a script



  • Hello,

    Before you start a script, it might be needed to ask the user for some settings before you can start the script.

    In this example we are simply going to bury bones and ask the user which bones he wants to bury. I am not going to show how to bury bones in this example, but only how you can get the information from the user.

    Simple solution
    If you only need to ask for 1 setting, the best way is to use the following script:

    String bones = "";
    
    @Override
    public void onStart() {
        String[] choices = {"Bones", "Big bones", "Baby dragon bones", "Dragon bones", "Wyvern " +
                "bones", "Wolf bones", "Monkey bones", "Bat bones", "Joge bones", "Zogre bones", "Fayrg bones", "Lava dragon bones", "Raurg bones", "Dagannoth bones", "Ourg bones", "Superior dragon bones"};
        bones = (String) JOptionPane.showInputDialog(null, "Select bones:", "[LUX] Bones Burier",
                JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
    }
    
    @Override
    public int loop() {
        if(!bones.equals("")) {
            //The bones string is not empty, so the user has chosen a bone to bury
            //Execute your script here...
            System.out.println("The user wants to bury: " + bones);
        }else {
            //The bones string is empty, the user didn't select a bone to bury yet
            System.out.println("Waiting for the user to select a bone");
        }
        return 0;
    }
    

    (Thanks @Spencer for the contribution!)

    Result:
    alt text

    Advanced solution
    If you want full controll over your JFrame, then you should use this solution. It is very easy to add components and ask the user for multiple settings before your script can start. (In this example i only ask for 1 setting, but if you understand how this code works then it should be very easy to ask for multiple settings)

    Example:

    //If this string is empty, the user didn't select a bone yet, otherwise this string contains the selected value from the user
    String bones = "";
    
    @Override
    public void onStart() {
        //Create a JFrame
        JFrame frame;
        frame = new JFrame("Select bones");
        frame.setLayout(null);
        frame.setSize(245, 80);
        frame.setVisible(true);
    
        //Creating a label
        final JLabel label = new JLabel();
        label.setSize(400, 100);
        label.setText("Select bones to bury:");
    
        //Creating a button to start the script
        JButton btnStart = new JButton("Start");
    
        //Creating a combobox
        String availableBones[] = {"Bones", "Big bones", "Baby dragon bones", "Dragon bones", "Wyvern bones", "Wolf bones", "Monkey bones", "Bat bones", "Joge bones", "Zogre bones", "Fayrg bones", "Lava dragon bones", "Raurg bones", "Dagannoth bones", "Ourg bones", "Superior dragon bones"};
        final JComboBox cb = new JComboBox(availableBones);
    
        //Positioning all components
        label.setVerticalAlignment(JLabel.TOP);
        label.setHorizontalAlignment(JLabel.LEFT);
        btnStart.setBounds(160, 25, 75, 20);
        cb.setBounds(5, 25, 150, 20);
    
        //Add all the components to the frame
        frame.add(cb);
        frame.add(label);
        frame.add(btnStart);
    
        //Create the button action
        btnStart.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
                //Set 'bones' to the selected value
                bones = ""+cb.getItemAt(cb.getSelectedIndex());
                //Close the frame and the script will start
                frame.dispatchEvent(new WindowEvent(frame,WindowEvent.WINDOW_CLOSING));
            }
        });
    }
    
    @Override
    public int loop() {
        if(!bones.equals("")) {
            //The bones string is not empty, so the user has chosen a bone to bury
            //Execute your script here...
            System.out.println("The user wants to bury: " + bones);
        }else {
            //The bones string is empty, the user didn't select a bone to bury yet
            System.out.println("Waiting for the user to select a bone");
        }
        return 0;
    }
    

    Result:
    alt text

    Hopefully this helps some people out to create their first little gui, if you have suggestions or want to add something to the script, please let me know in the comments!



  • Needed a hand with this thank you!


  • Contributor Sponsor Staff Director

    A small tip for single input dialogs like this is to use JOptionPane.showInputDialog 🙂

            String[] choices = {"Bones", "Big bones", "Baby dragon bones", "Dragon bones", "Wyvern " +
                    "bones", "Wolf bones", "Monkey bones", "Bat bones", "Joge bones", "Zogre bones", "Fayrg bones", "Lava dragon bones", "Raurg bones", "Dagannoth bones", "Ourg bones", "Superior dragon bones"};
            String choice = (String) JOptionPane.showInputDialog(null, "Select a bone", "Bone burier",
                    JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
    


  • @Spencer Thanks, I will update this probably tomorrow.



  • I have added a simple and advanced part, thanks @Spencer for the single input dialog!



  • I was getting a massive error and found out that I needed this in order for it to work:

    public void onStart() {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    String[] choices = {"Bones", "Big bones", "Baby dragon bones", "Dragon bones", "Wyvern " +
                            "bones", "Wolf bones", "Monkey bones", "Bat bones", "Joge bones", "Zogre bones", "Fayrg bones", "Lava dragon bones", "Raurg bones", "Dagannoth bones", "Ourg bones", "Superior dragon bones"};
                    bones = (String) JOptionPane.showInputDialog(null, "Select bones:", "[LUX] Bones Burier",
                            JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
                }
            });
        }
    


  • @Transported Can you please recreate the error and post the details here?

    Normally you shouldn't call the run function like that.



  • @luxiflex

    org.pushingpixels.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    	at org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:1718)
    	at org.pushingpixels.substance.internal.ui.SubstancePanelUI.createUI(SubstancePanelUI.java:51)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:770)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JPanel.updateUI(JPanel.java:126)
    	at javax.swing.JPanel.<init>(JPanel.java:86)
    	at javax.swing.JPanel.<init>(JPanel.java:109)
    	at javax.swing.JPanel.<init>(JPanel.java:117)
    	at javax.swing.JRootPane.createGlassPane(JRootPane.java:546)
    	at javax.swing.JRootPane.<init>(JRootPane.java:366)
    	at javax.swing.JFrame.createRootPane(JFrame.java:286)
    	at javax.swing.JFrame.frameInit(JFrame.java:267)
    	at javax.swing.JFrame.<init>(JFrame.java:234)
    	at Main.onStart(Main.java:40)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    UIDefaults.getUI() failed: createUI() failed for javax.swing.JPanel[,0,0,0x0,invalid,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=] java.lang.reflect.InvocationTargetException
    java.lang.Error
    	at javax.swing.UIDefaults.getUIError(UIDefaults.java:731)
    	at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:776)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JPanel.updateUI(JPanel.java:126)
    	at javax.swing.JPanel.<init>(JPanel.java:86)
    	at javax.swing.JPanel.<init>(JPanel.java:109)
    	at javax.swing.JPanel.<init>(JPanel.java:117)
    	at javax.swing.JRootPane.createGlassPane(JRootPane.java:546)
    	at javax.swing.JRootPane.<init>(JRootPane.java:366)
    	at javax.swing.JFrame.createRootPane(JFrame.java:286)
    	at javax.swing.JFrame.frameInit(JFrame.java:267)
    	at javax.swing.JFrame.<init>(JFrame.java:234)
    	at Main.onStart(Main.java:40)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    org.pushingpixels.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    	at org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:1718)
    	at org.pushingpixels.substance.internal.ui.SubstancePanelUI.createUI(SubstancePanelUI.java:51)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:770)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JPanel.updateUI(JPanel.java:126)
    	at javax.swing.JPanel.<init>(JPanel.java:86)
    	at javax.swing.JPanel.<init>(JPanel.java:109)
    	at javax.swing.JPanel.<init>(JPanel.java:117)
    	at javax.swing.JRootPane.createContentPane(JRootPane.java:521)
    	at javax.swing.JRootPane.<init>(JRootPane.java:368)
    	at javax.swing.JFrame.createRootPane(JFrame.java:286)
    	at javax.swing.JFrame.frameInit(JFrame.java:267)
    	at javax.swing.JFrame.<init>(JFrame.java:234)
    	at Main.onStart(Main.java:40)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    UIDefaults.getUI() failed: createUI() failed for javax.swing.JPanel[,0,0,0x0,invalid,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=] java.lang.reflect.InvocationTargetException
    java.lang.Error
    	at javax.swing.UIDefaults.getUIError(UIDefaults.java:731)
    	at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:776)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JPanel.updateUI(JPanel.java:126)
    	at javax.swing.JPanel.<init>(JPanel.java:86)
    	at javax.swing.JPanel.<init>(JPanel.java:109)
    	at javax.swing.JPanel.<init>(JPanel.java:117)
    	at javax.swing.JRootPane.createContentPane(JRootPane.java:521)
    	at javax.swing.JRootPane.<init>(JRootPane.java:368)
    	at javax.swing.JFrame.createRootPane(JFrame.java:286)
    	at javax.swing.JFrame.frameInit(JFrame.java:267)
    	at javax.swing.JFrame.<init>(JFrame.java:234)
    	at Main.onStart(Main.java:40)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    org.pushingpixels.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    	at org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:1718)
    	at org.pushingpixels.substance.internal.ui.SubstanceRootPaneUI.createUI(SubstanceRootPaneUI.java:158)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:770)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JRootPane.updateUI(JRootPane.java:484)
    	at javax.swing.JRootPane.<init>(JRootPane.java:371)
    	at javax.swing.JFrame.createRootPane(JFrame.java:286)
    	at javax.swing.JFrame.frameInit(JFrame.java:267)
    	at javax.swing.JFrame.<init>(JFrame.java:234)
    	at Main.onStart(Main.java:40)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    UIDefaults.getUI() failed: createUI() failed for javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=1,maximumSize=,minimumSize=,preferredSize=] java.lang.reflect.InvocationTargetException
    java.lang.Error
    	at javax.swing.UIDefaults.getUIError(UIDefaults.java:731)
    	at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:776)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JRootPane.updateUI(JRootPane.java:484)
    	at javax.swing.JRootPane.<init>(JRootPane.java:371)
    	at javax.swing.JFrame.createRootPane(JFrame.java:286)
    	at javax.swing.JFrame.frameInit(JFrame.java:267)
    	at javax.swing.JFrame.<init>(JFrame.java:234)
    	at Main.onStart(Main.java:40)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    org.pushingpixels.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    	at org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:1718)
    	at org.pushingpixels.substance.internal.ui.SubstanceLabelUI.createUI(SubstanceLabelUI.java:60)
    	at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:770)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JLabel.updateUI(JLabel.java:275)
    	at javax.swing.JLabel.<init>(JLabel.java:164)
    	at javax.swing.JLabel.<init>(JLabel.java:235)
    	at Main.onStart(Main.java:46)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    UIDefaults.getUI() failed: createUI() failed for javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,horizontalAlignment=LEADING,horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,text=,verticalAlignment=CENTER,verticalTextPosition=CENTER] java.lang.reflect.InvocationTargetException
    java.lang.Error
    	at javax.swing.UIDefaults.getUIError(UIDefaults.java:731)
    	at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:776)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JLabel.updateUI(JLabel.java:275)
    	at javax.swing.JLabel.<init>(JLabel.java:164)
    	at javax.swing.JLabel.<init>(JLabel.java:235)
    	at Main.onStart(Main.java:46)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    org.pushingpixels.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    	at org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:1718)
    	at org.pushingpixels.substance.internal.ui.SubstanceButtonUI.createUI(SubstanceButtonUI.java:139)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:770)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JButton.updateUI(JButton.java:147)
    	at javax.swing.AbstractButton.init(AbstractButton.java:2176)
    	at javax.swing.JButton.<init>(JButton.java:137)
    	at javax.swing.JButton.<init>(JButton.java:110)
    	at Main.onStart(Main.java:51)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    UIDefaults.getUI() failed: createUI() failed for javax.swing.JButton[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Start,defaultCapable=true] java.lang.reflect.InvocationTargetException
    java.lang.Error
    	at javax.swing.UIDefaults.getUIError(UIDefaults.java:731)
    	at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:776)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JButton.updateUI(JButton.java:147)
    	at javax.swing.AbstractButton.init(AbstractButton.java:2176)
    	at javax.swing.JButton.<init>(JButton.java:137)
    	at javax.swing.JButton.<init>(JButton.java:110)
    	at Main.onStart(Main.java:51)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    org.pushingpixels.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    	at org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:1718)
    	at org.pushingpixels.substance.internal.ui.SubstanceComboBoxUI.createUI(SubstanceComboBoxUI.java:86)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:770)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JComboBox.updateUI(JComboBox.java:266)
    	at javax.swing.JComboBox.init(JComboBox.java:231)
    	at javax.swing.JComboBox.<init>(JComboBox.java:197)
    	at Main.onStart(Main.java:55)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    UIDefaults.getUI() failed: createUI() failed for javax.swing.JComboBox[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=8,maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=false,maximumRowCount=8,selectedItemReminder=Bones] java.lang.reflect.InvocationTargetException
    java.lang.Error
    	at javax.swing.UIDefaults.getUIError(UIDefaults.java:731)
    	at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    	at javax.swing.UIDefaults.getUI(UIDefaults.java:776)
    	at javax.swing.UIManager.getUI(UIManager.java:1016)
    	at javax.swing.JComboBox.updateUI(JComboBox.java:266)
    	at javax.swing.JComboBox.init(JComboBox.java:231)
    	at javax.swing.JComboBox.<init>(JComboBox.java:197)
    	at Main.onStart(Main.java:55)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    java.lang.NullPointerException
    	at javax.swing.JComboBox.setPopupVisible(JComboBox.java:816)
    	at javax.swing.JComboBox.hidePopup(JComboBox.java:809)
    	at javax.swing.JComboBox$1.ancestorAdded(JComboBox.java:236)
    	at javax.swing.AncestorNotifier.fireAncestorAdded(AncestorNotifier.java:86)
    	at javax.swing.AncestorNotifier.propertyChange(AncestorNotifier.java:223)
    	at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
    	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
    	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
    	at java.awt.Component.firePropertyChange(Component.java:8434)
    	at javax.swing.JComponent.addNotify(JComponent.java:4741)
    	at java.awt.Container.addImpl(Container.java:1124)
    	at java.awt.Container.add(Container.java:1007)
    	at javax.swing.JFrame.addImpl(JFrame.java:567)
    	at java.awt.Container.add(Container.java:419)
    	at Main.onStart(Main.java:64)
    	at org.rspeer.script.Script.start(wd:124)
    	at org.rspeer.script.10.iiIIiiiiiIiii(jn:205)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:66)
    	at org.rspeer.10.iiIIiiiiiIiii(vz:98)
    	at org.rspeer.5.51.iiIiIiiiiIIIi(ih:161)
    	at org.rspeer.5.51.iiIIiiiiiIiii(ih:168)
    	at org.rspeer.Bootstrap.lambda$waitForLoadAndExecute$1(ip:183)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    java.lang.NullPointerException
    	at javax.swing.LayoutFocusTraversalPolicy.accept(LayoutFocusTraversalPolicy.java:236)
    	at javax.swing.SortingFocusTraversalPolicy.getFirstComponent(SortingFocusTraversalPolicy.java:514)
    	at javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(LayoutFocusTraversalPolicy.java:166)
    	at javax.swing.SortingFocusTraversalPolicy.getDefaultComponent(SortingFocusTraversalPolicy.java:593)
    	at java.awt.FocusTraversalPolicy.getInitialComponent(FocusTraversalPolicy.java:169)
    	at java.awt.Window.getMostRecentFocusOwner(Window.java:2343)
    	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:754)
    	at java.awt.Component.dispatchEventImpl(Component.java:4760)
    	at java.awt.Container.dispatchEventImpl(Container.java:2297)
    	at java.awt.Window.dispatchEventImpl(Window.java:2746)
    	at java.awt.Component.dispatchEvent(Component.java:4711)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    	at java.awt.EventQueue$4.run(EventQueue.java:733)
    	at java.awt.EventQueue$4.run(EventQueue.java:731)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    	at java.awt.SequencedEvent.dispatch(SequencedEvent.java:128)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    	at java.awt.EventQueue$4.run(EventQueue.java:733)
    	at java.awt.EventQueue$4.run(EventQueue.java:731)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    java.lang.NullPointerException
    	at javax.swing.LayoutFocusTraversalPolicy.accept(LayoutFocusTraversalPolicy.java:236)
    	at javax.swing.SortingFocusTraversalPolicy.getFirstComponent(SortingFocusTraversalPolicy.java:514)
    	at javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(LayoutFocusTraversalPolicy.java:166)
    	at javax.swing.SortingFocusTraversalPolicy.getDefaultComponent(SortingFocusTraversalPolicy.java:593)
    	at java.awt.FocusTraversalPolicy.getInitialComponent(FocusTraversalPolicy.java:169)
    	at java.awt.Window.getMostRecentFocusOwner(Window.java:2343)
    	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:754)
    	at java.awt.Component.dispatchEventImpl(Component.java:4760)
    	at java.awt.Container.dispatchEventImpl(Container.java:2297)
    	at java.awt.Window.dispatchEventImpl(Window.java:2746)
    	at java.awt.Component.dispatchEvent(Component.java:4711)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    	at java.awt.EventQueue$4.run(EventQueue.java:733)
    	at java.awt.EventQueue$4.run(EventQueue.java:731)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    	at java.awt.SentEvent.dispatch(SentEvent.java:70)
    	at java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent.dispatch(DefaultKeyboardFocusManager.java:239)
    	at java.awt.DefaultKeyboardFocusManager.sendMessage(DefaultKeyboardFocusManager.java:266)
    	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:370)
    	at java.awt.Component.dispatchEventImpl(Component.java:4760)
    	at java.awt.Container.dispatchEventImpl(Container.java:2297)
    	at java.awt.Window.dispatchEventImpl(Window.java:2746)
    	at java.awt.Component.dispatchEvent(Component.java:4711)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    	at java.awt.EventQueue$4.run(EventQueue.java:733)
    	at java.awt.EventQueue$4.run(EventQueue.java:731)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    	at java.awt.SequencedEvent.dispatch(SequencedEvent.java:128)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    	at java.awt.EventQueue$4.run(EventQueue.java:733)
    	at java.awt.EventQueue$4.run(EventQueue.java:731)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    
    

    hope this helps.
    It's a runtime error btw.


  • Contributor Sponsor Staff Director

    Yeah substance look and feel requires component creation on the event dispatch thread so you must wrap it in EventQueue.invokeLater(() -> {....});



  • @Transported @Spencer
    Okay I didn't know about this, thanks for the solution!


 

24
Online

17.7k
Users

1.5k
Topics

19.6k
Posts