Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8179665

[Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location

    XMLWordPrintable

Details

    • b172
    • x86_64
    • windows

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.8.0_131"
        Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
        Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows [Version 6.1.7601]

        A DESCRIPTION OF THE PROBLEM :
        If a modal dialog is made visible after its parent frame is set to always-on-top, closed by hitting the "Enter" key which activates a default button, then the parent frame is set to not-always-on-top, an IllegalComponentStateException is raised.

        The stack dump looks the same as in http://bugs.java.com/view_bug.do?bug_id=8159242, though the description of that bug doesn't seem to have anything to do with the stack dump.

        There is good reason to set the dialog's frame parent to always-on-top while it is up, if the dialog itself is always-on-top. If another modal dialog pops up while it is up, that other dialog may otherwise be hidden, and the application will appear to be locked up. There are also good reasons to make all modal dialogs always-on-top.

        REGRESSION. Last worked in version 8u121

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile and run code, hit "Enter" to close the dialog.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Expect no exceptions.
        ACTUAL -
        An IllegalComponentStateException occurs.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        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)


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.swing.*;
        import java.awt.*;
        import java.awt.event.*;


        public class ICSEBug {

           public static void main(String[] args) {
              SwingUtilities.invokeLater(
                 new Runnable() {
                    public void run() {
                       go();
                    }
                 });
           }

           static void go() {
              JFrame f = new JFrame();
              f.setVisible(true);
              final JDialog d = new JDialog(f);
              d.getContentPane().add(new JTextField(20), "Center");
              JButton closeButton = new JButton("Close");
              closeButton.addActionListener(
                 new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                       d.setVisible(false);
                    }
                 });
              d.getContentPane().add(closeButton, "South");
              d.getRootPane().setDefaultButton(closeButton);
              d.setModal(true);
              d.setSize(300, 300);
              f.setAlwaysOnTop(true);
              d.setVisible(true);
              f.setAlwaysOnTop(false);
           }

        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        If the exception is caught in a global uncaught exception handler, it can be ignored. It doesn't seem to cause any problems.

        Attachments

          Issue Links

            Activity

              People

                ssadetsky Semyon Sadetsky (Inactive)
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: