changeset 4185:c92013229eda

RT-30649: SwingNode: Swing events should not be dispatched if content is not set Reviewed-by: art
author ant <anton.tarasov@oracle.com>
date Fri, 05 Jul 2013 15:14:00 +0400
parents 4d91fcff597d
children b746a171dc3a
files modules/swing/src/main/java/javafx/embed/swing/SwingNode.java
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/swing/src/main/java/javafx/embed/swing/SwingNode.java	Fri Jul 05 14:15:30 2013 +0400
+++ b/modules/swing/src/main/java/javafx/embed/swing/SwingNode.java	Fri Jul 05 15:14:00 2013 +0400
@@ -585,6 +585,10 @@
             {
                 SwingNode.this.requestFocus();
             }
+            JLightweightFrame frame = lwFrame;
+            if (frame == null) {
+                return;
+            }
             int swingID = SwingEvents.fxMouseEventTypeToMouseID(event);
             if (swingID < 0) {
                 return;
@@ -596,7 +600,7 @@
             long swingWhen = System.currentTimeMillis();
             java.awt.event.MouseEvent mouseEvent =
                     new java.awt.event.MouseEvent(
-                        lwFrame, swingID, swingWhen, swingModifiers,
+                        frame, swingID, swingWhen, swingModifiers,
                         (int)event.getX(), (int)event.getY(), (int)event.getScreenX(), (int)event.getSceneY(),
                         event.getClickCount(), swingPopupTrigger, swingButton);
             AccessController.doPrivileged(new PostEventAction(mouseEvent));
@@ -606,6 +610,10 @@
     private class SwingKeyEventHandler implements EventHandler<KeyEvent> {
         @Override
         public void handle(KeyEvent event) {
+            JLightweightFrame frame = lwFrame;
+            if (frame == null) {
+                return;
+            }
             if (event.getCharacter().isEmpty()) {
                 // TODO: should we post an "empty" character?
                 return;
@@ -633,7 +641,7 @@
             char swingChar = event.getCharacter().charAt(0);
             long swingWhen = System.currentTimeMillis();
             java.awt.event.KeyEvent keyEvent = new java.awt.event.KeyEvent(
-                    lwFrame, swingID, swingWhen, swingModifiers,
+                    frame, swingID, swingWhen, swingModifiers,
                     swingKeyCode, swingChar);
             AccessController.doPrivileged(new PostEventAction(keyEvent));
         }