0

i have this wierd exception wheere it's stack trace IS NOT HELPING OR SHOWING WHERE IT IS FROM !!!!!!!!! .

I'v searched about it and the usefull resault with someone who did have the same glitch when using a modal JDialog instances and disposing it with KeyListner while the frame owner alwaysOnTop proprety is set to false .

But in my case i havn't use any dialogs at all!! here is the exception stack trace :

Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:2062)
at java.awt.Component.getLocationOnScreen(Component.java:2036)
at javax.swing.text.JTextComponent$InputMethodRequestsHandler.getTextLocation(JTextComponent.java:4643)
at sun.awt.im.InputMethodContext.getTextLocation(InputMethodContext.java:278)
at sun.awt.windows.WInputMethod$1.run(WInputMethod.java:588)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
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:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
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)

I haven't used this app for a while and i can confirm that no one did mess with the code ,earlier i was devoloping the app in a linux enviroment it didn't throw that exception , but after changing my laptop and the enviroment to windows somehow this is happenning . I need to deliver my app soon and this exception have a strange thing that it's not thrown every time i open my app ! and i couldn't face any pattern to notice when it wil be thrown or what specific action that would do that . what am asing is if any one did face off a strange case like this what is it usually from ?? and thanks in advance .

Edit
Found the solution !I just found it at bugzilla it seems to be some sort of bug when is extending JRootPane without implemeting RootPaneContainer in windows in Runtime: Java(TM) SE Runtime Environment 1.8.0_141-b15 with some gpu and methods related stuff i couldn't understand and if also used modal JDialogs without the owner always on top when using the default rootpane button of the dialogs to exit .

  • You are trying to get location of text component? – muasif80 Feb 24 '19 at 02:31
  • nope, nothing about trying to get a location of any component – a lovely person Feb 24 '19 at 02:32
  • 2
    `it's not thrown every time i open my app` - Swing components should be created and updated on the Event Dispatch Thread (EDT), otherwise you can have random results. Read the Swing tutorial on [Concurrency](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html) for more information and examples of the proper way to create the GUI. – camickr Feb 24 '19 at 02:32
  • Is this complete stack trace? Where is your code? – muasif80 Feb 24 '19 at 02:36
  • i did a long time searching in this too and am sure of my code in this as i used ```SwingUtitlities.invokeLater``` in the main ,and for the rest of my thier is no any gui related changes in my app. – a lovely person Feb 24 '19 at 02:38
  • Once i had the same problem. https://stackoverflow.com/questions/48934001/illegalcomponentstateexception-when-changing-language-in-a-jtextfield-inside-a-j – George Z. Feb 24 '19 at 02:39
  • this is the full stack trace and it's defnetly not about the code @muasif80 it worked perfectly fine on linux but in windows it does this strange exception . – a lovely person Feb 24 '19 at 02:40
  • @alovelyperson I understand you are using `invokeLater` in the main, but do you ever branch out via `SwingWorker`? – ryvantage Feb 24 '19 at 02:44
  • @GeorgeZ. i think we got something here !! that dude who commented on your post said he didn't hava any problems but you did have it !! he said he used JDK 1.8.0_112 please provide your jdk version to compare , may be it's a bug on a specific version/s!! – a lovely person Feb 24 '19 at 02:44
  • 1
    We don't have all night to make wild guesses. Start to do some basic debugging. Remove blocks of code until it starts working. Then you know what you just removed and have isolated the problem. Then you solve the problem. Or you have useful information to add to the question. You have been given the main cause of random problems. Post your [mcve] that demonstrates the problem. – camickr Feb 24 '19 at 02:45
  • I had this exception long time ago and i did not write down my jre/jdk version. So...test my code with your jdk and check if you got the same exception. – George Z. Feb 24 '19 at 02:52
  • This exception is only thrown when `Component#isVisible` returns false, or `Component::peer` is null. I believe these both occur either when you haven't added the component to a parent, or if the peer has not finished constructing via #addNotify or some other form. It definitely sounds like a concurrency issue to me, you should post some of your code involving the creation of the components (use a debugger to determine when it arises and which component is hurting you). – Rogue Feb 24 '19 at 02:52

1 Answers1

1

I used to get regular Swing Exceptions without a traceable stack trace. It was because I was violating the rules regarding concurrency in Swing. This SO answer elaborates: SwingWorker ProgressBar. Basically, make sure all of your Swing code is being called on the Event Dispatch Thread.

ryvantage
  • 13,064
  • 15
  • 63
  • 112