< prev index next >

src/java.desktop/share/classes/java/awt/doc-files/FocusSpec.html

Print this page


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

  34       <h1>The AWT Focus Subsystem</h1>
  35 
  36     <p>
  37       Prior to Java 2 Standard Edition, JDK 1.4, the AWT focus subsystem
  38       was inadequate. It suffered from major design and API problems,
  39       as well as over a hundred open bugs. Many of these bugs were caused by
  40       platform inconsistencies, or incompatibilities between the native
  41       focus system for heavyweights and the Java focus system for
  42       lightweights.
  43     <p>
  44       The single worst problem with the AWT focus implementation was the
  45       inability to query for the currently focused Component. Not only was
  46       there no API for such a query, but also, because of an insufficient
  47       architecture, such information was not even maintained by the code.
  48     <p>
  49       Almost as bad was the inability of lightweight children of a Window
  50       (not a Frame or a Dialog) to receive keyboard input. This problem
  51       existed because Windows never received <code>WINDOW_ACTIVATED</code>
  52       events and thus could never be activated, and only active Windows
  53       could contain focused Components.


1345           traversal operations, and
1346           <code>Component.handleEvent()</code> will no longer be invoked
1347           for such events. Previously, AWT Components saw these events
1348           and had an opportunity to consume them before AWT
1349           initiated focus traversal. Code that requires this
1350           functionality should instead disable focus traversal keys on
1351           its <code>Component</code>s and handle focus traversal
1352           itself. Alternately, the code can use an
1353           <code>AWTEventListener</code> or
1354           <code>KeyEventDispatcher</code> to pre-listen to all
1355           <code>KeyEvent</code>s.
1356     </ol>
1357   <p><b>Changes specific to Microsoft Windows:</b>
1358     <ol>
1359       <li><code>Window.toBack()</code> changes the focused Window to
1360           the top-most Window after the Z-order change.
1361       <li><code>requestFocus()</code> now allows cross-Window focus
1362           change requests in all cases. Previously, requests were granted
1363           for heavyweights, but denied for lightweights.
1364     </ol>

1365   </main>
1366 </body>
1367 </html>
   1 <!doctype html>
   2 <html lang="en">
   3 <head>
   4   <meta charset="utf-8"/>
   5   <title>The AWT Focus Subsystem</title>
   6 </head>
   7 <!--
   8  Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
   9  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  10 
  11  This code is free software; you can redistribute it and/or modify it
  12  under the terms of the GNU General Public License version 2 only, as
  13  published by the Free Software Foundation.  Oracle designates this
  14  particular file as subject to the "Classpath" exception as provided
  15  by Oracle in the LICENSE file that accompanied this code.
  16 
  17  This code is distributed in the hope that it will be useful, but WITHOUT
  18  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  19  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  20  version 2 for more details (a copy is included in the LICENSE file that
  21  accompanied this code).
  22 
  23  You should have received a copy of the GNU General Public License version
  24  2 along with this work; if not, write to the Free Software Foundation,
  25  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  26 
  27  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  28  or visit www.oracle.com if you need additional information or have any
  29  questions.
  30 -->
  31 
  32     <body>
  33     <main role="main">
  34     <div class="contentContainer">
  35       <h1>The AWT Focus Subsystem</h1>
  36 
  37     <p>
  38       Prior to Java 2 Standard Edition, JDK 1.4, the AWT focus subsystem
  39       was inadequate. It suffered from major design and API problems,
  40       as well as over a hundred open bugs. Many of these bugs were caused by
  41       platform inconsistencies, or incompatibilities between the native
  42       focus system for heavyweights and the Java focus system for
  43       lightweights.
  44     <p>
  45       The single worst problem with the AWT focus implementation was the
  46       inability to query for the currently focused Component. Not only was
  47       there no API for such a query, but also, because of an insufficient
  48       architecture, such information was not even maintained by the code.
  49     <p>
  50       Almost as bad was the inability of lightweight children of a Window
  51       (not a Frame or a Dialog) to receive keyboard input. This problem
  52       existed because Windows never received <code>WINDOW_ACTIVATED</code>
  53       events and thus could never be activated, and only active Windows
  54       could contain focused Components.


1346           traversal operations, and
1347           <code>Component.handleEvent()</code> will no longer be invoked
1348           for such events. Previously, AWT Components saw these events
1349           and had an opportunity to consume them before AWT
1350           initiated focus traversal. Code that requires this
1351           functionality should instead disable focus traversal keys on
1352           its <code>Component</code>s and handle focus traversal
1353           itself. Alternately, the code can use an
1354           <code>AWTEventListener</code> or
1355           <code>KeyEventDispatcher</code> to pre-listen to all
1356           <code>KeyEvent</code>s.
1357     </ol>
1358   <p><b>Changes specific to Microsoft Windows:</b>
1359     <ol>
1360       <li><code>Window.toBack()</code> changes the focused Window to
1361           the top-most Window after the Z-order change.
1362       <li><code>requestFocus()</code> now allows cross-Window focus
1363           change requests in all cases. Previously, requests were granted
1364           for heavyweights, but denied for lightweights.
1365     </ol>
1366   </div>
1367   </main>
1368 </body>
1369 </html>
< prev index next >