Skip to content

Closing window with currently opened date picker pop up yields exception #82

@WiseEagleOwl

Description

@WiseEagleOwl

Setup:

  • open JFrame window with a DatePicker on it.
  • the date picker popup (the one to visually select a date) is opened

Problem:

Closing the JFrame-window without closing the pop up first yields the following exception:

Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
	at java.desktop/java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:2101)
	at java.desktop/java.awt.Component.getLocationOnScreen(Component.java:2075)
	at com.github.lgooddatepicker.zinternaltools.InternalUtilities.isMouseWithinComponent(InternalUtilities.java:417)
	at com.github.lgooddatepicker.zinternaltools.CustomPopup.windowLostFocus(CustomPopup.java:267)
	at java.desktop/java.awt.Window.processWindowFocusEvent(Window.java:2128)
	at java.desktop/java.awt.Window.processEvent(Window.java:2041)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5008)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
	at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1950)
	at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1059)
	at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:813)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4889)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
	at [...]

Steps to Reproduce:

The exception can be reproduced with the following code:

DatePicker datePicker = new DatePicker();
JFrame testWin = new JFrame();
testWin.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
testWin.add(datePicker);
testWin.pack();
testWin.setVisible(true);
Thread.sleep(20);
datePicker.openPopup();
Thread.sleep(20);
testWin.dispatchEvent(new WindowEvent(testWin, WindowEvent.WINDOW_CLOSING));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions