Note that there are some explanatory texts on larger screens.

plurals
  1. POJOptionPane gives an error
    primarykey
    data
    text
    <p>I want to handle some exceptions using <code>JOptionPane</code>s. This is the main method:</p> <pre><code>public class MainRun { public static void main(String args[]){ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(new SubstanceRavenGraphiteGlassLookAndFeel()); }catch (Exception e){ e.printStackTrace(); } new MainGui().setVisible(true); new Initialized().start(); new PriorityMessageQueue().start(); } }); </code></pre> <p><code>MainGui</code> is the main window (<code>JFrame</code>) of the application. I handled exception inside the <code>PriorityMessageQueue</code> thread.</p> <pre><code>public class PriorityMessageQueue extends Thread { @Override public void run() { while (true) { try { instantMessages = instant.getMobitelMessagesToBeSent(); } catch (Exception ex) { JOptionPane.showMessageDialog( null, ex.getMessage(), "Database Error", JOptionPane.ERROR_MESSAGE); } ... </code></pre> <p>after I run this, I'm getting an error</p> <pre><code> org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread at org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:2312) at org.jvnet.substance.SubstanceOptionPaneUI.createUI(SubstanceOptionPaneUI.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:37) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:244) at javax.swing.UIDefaults.getUI(UIDefaults.java:752) at javax.swing.UIManager.getUI(UIManager.java:989) at javax.swing.JOptionPane.updateUI(JOptionPane.java:1859) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1822) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1785) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1753) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1731) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1711) at GUI.MainGui.showOptionPane(MainGui.java:1039) at SMS.PriorityMessageQueue.run(PriorityMessageQueue.java:86) UIDefaults.getUI() failed: createUI() failed for javax.swing.JOptionPane [,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,p referredSize=,icon=,initialValue=,message=DatabaseConnection class connect,messageType=ERROR_MESSAGE,optionType=DEFAULT_OPTION,wantsInput=false] java.lang.reflect.InvocationTargetException java.lang.Error at javax.swing.UIDefaults.getUIError(UIDefaults.java:712) at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:133) at javax.swing.UIDefaults.getUI(UIDefaults.java:758) at javax.swing.UIManager.getUI(UIManager.java:989) at javax.swing.JOptionPane.updateUI(JOptionPane.java:1859) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1822) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1785) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1753) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1731) at javax.swing.JOptionPane.&lt;init&gt;(JOptionPane.java:1711) at GUI.MainGui.showOptionPane(MainGui.java:1039) at SMS.PriorityMessageQueue.run(PriorityMessageQueue.java:86) </code></pre> <p>And the <code>JOptionPane</code> will not display properly!</p> <p><img src="https://i.stack.imgur.com/3aFZj.jpg" alt="enter image description here"></p> <p>Instead of passing <code>null</code> to <code>JOptionPane</code>, how can I get the parentComponent (<code>MainGui</code> <code>JFrame</code>)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload