< prev index next >

src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  78     private boolean consumeNextKeyTyped;
  79     private Component restoreFocusTo;
  80 
  81     private static boolean fxAppThreadIsDispatchThread;
  82 
  83     static {
  84         AWTAccessor.setDefaultKeyboardFocusManagerAccessor(
  85             new AWTAccessor.DefaultKeyboardFocusManagerAccessor() {
  86                 public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e) {
  87                     dkfm.consumeNextKeyTyped(e);
  88                 }
  89             });
  90         AccessController.doPrivileged(new PrivilegedAction<Object>() {
  91             public Object run() {
  92                 fxAppThreadIsDispatchThread =
  93                         "true".equals(System.getProperty("javafx.embed.singleThread"));
  94                 return null;
  95             }
  96         });
  97     }





  98 
  99     private static class TypeAheadMarker {
 100         long after;
 101         Component untilFocused;
 102 
 103         TypeAheadMarker(long after, Component untilFocused) {
 104             this.after = after;
 105             this.untilFocused = untilFocused;
 106         }
 107         /**
 108          * Returns string representation of the marker
 109          */
 110         public String toString() {
 111             return ">>> Marker after " + after + " on " + untilFocused;
 112         }
 113     }
 114 
 115     private Window getOwningFrameDialog(Window window) {
 116         while (window != null && !(window instanceof Frame ||
 117                                    window instanceof Dialog)) {


   1 /*
   2  * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  78     private boolean consumeNextKeyTyped;
  79     private Component restoreFocusTo;
  80 
  81     private static boolean fxAppThreadIsDispatchThread;
  82 
  83     static {
  84         AWTAccessor.setDefaultKeyboardFocusManagerAccessor(
  85             new AWTAccessor.DefaultKeyboardFocusManagerAccessor() {
  86                 public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e) {
  87                     dkfm.consumeNextKeyTyped(e);
  88                 }
  89             });
  90         AccessController.doPrivileged(new PrivilegedAction<Object>() {
  91             public Object run() {
  92                 fxAppThreadIsDispatchThread =
  93                         "true".equals(System.getProperty("javafx.embed.singleThread"));
  94                 return null;
  95             }
  96         });
  97     }
  98 
  99     /**
 100      * Constructs a {@code DefaultKeyboardFocusManager}.
 101      */
 102     public DefaultKeyboardFocusManager() {}
 103 
 104     private static class TypeAheadMarker {
 105         long after;
 106         Component untilFocused;
 107 
 108         TypeAheadMarker(long after, Component untilFocused) {
 109             this.after = after;
 110             this.untilFocused = untilFocused;
 111         }
 112         /**
 113          * Returns string representation of the marker
 114          */
 115         public String toString() {
 116             return ">>> Marker after " + after + " on " + untilFocused;
 117         }
 118     }
 119 
 120     private Window getOwningFrameDialog(Window window) {
 121         while (window != null && !(window instanceof Frame ||
 122                                    window instanceof Dialog)) {


< prev index next >