JAG98 4 Share Posted March 24, 2021 Wrote the first ever script for a gui. A simple small snippet with one ComboBox, a start button and a label. It selects from the user what is to be looted. Got a big pile of error. Here is what was copied to the clipboard. Spoiler 7:02:34 pm: [ERROR] Swing threading error:: org.pushingpixels.substance.api.UiThreadingViolationException: Swing component creation must be done on the Event Dispatch Thread. Try wrapping your method in SwingUtilities#invokeLater. at org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java) at org.pushingpixels.substance.internal.ui.SubstanceLabelUI.createUI(SubstanceLabelUI.java) at jdk.internal.reflect.GeneratedMethodAccessor6.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at java.base/sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:260) at java.desktop/javax.swing.UIDefaults.getUI(UIDefaults.java:806) at java.desktop/javax.swing.UIManager.getUI(UIManager.java:1064) at java.desktop/javax.swing.JLabel.updateUI(JLabel.java:270) at java.desktop/javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1363) at java.desktop/javax.swing.SwingUtilities.updateComponentTreeUI(SwingUtilities.java:1354) at java.desktop/javax.swing.JComboBox.updateUI(JComboBox.java:281) at java.desktop/javax.swing.JComboBox.init(JComboBox.java:236) at java.desktop/javax.swing.JComboBox.<init>(JComboBox.java:230) at GUISource.initComponents(GUISource.java:19) at GUISource.<init>(GUISource.java:9) at CombatTrainer.onStart(CombatTrainer.java:45) at org.dreambot.api.script.AbstractScript.run(AbstractScript.java) at java.base/java.lang.Thread.run(Thread.java:832) So, what can be done? Don't really know much about Swing and mostly based this script off of a YT guide. ETA: After that error, the script works just fine. Link to comment Share on other sites More sharing options...
Neffarion 486 Share Posted March 24, 2021 https://dreambot.org/guides/scripter-guide/troubleshooting/ Link to comment Share on other sites More sharing options...
Neffarion 486 Share Posted March 24, 2021 If that doesnt help then post the code so we can help Link to comment Share on other sites More sharing options...
flipjazz 13 Share Posted March 24, 2021 The error is saying you need to wrap the code which creates the GUI in a lambda put into SwingUtilities.invokeLater(..). SwingUtilities.invokeLater(() => createGUI()); Imagine createGUI() is entrypoint function which creates the JPanels and stuff. You can put this in the onStart() of your script. (reference: https://dreambot.org/forums/index.php?/topic/8530-scripting-101/ see first note in the GUI section) Link to comment Share on other sites More sharing options...
JAG98 4 Author Share Posted March 25, 2021 On 3/24/2021 at 7:52 PM, flipjazz said: The error is saying you need to wrap the code which creates the GUI in a lambda put into SwingUtilities.invokeLater(..). SwingUtilities.invokeLater(() => createGUI()); Imagine createGUI() is entrypoint function which creates the JPanels and stuff. You can put this in the onStart() of your script. (reference: https://dreambot.org/forums/index.php?/topic/8530-scripting-101/ see first note in the GUI section) On 3/24/2021 at 7:21 PM, Neffarion said: https://dreambot.org/guides/scripter-guide/troubleshooting/ Yeah wrapped up the createGUI() in SwingUtilities.invokeLater(). Worked like a charm. Thanks you two! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.