modules/graphics/src/main/java/com/sun/javafx/stage/StagePeerListener.java

Print this page


   1 /*
   2  * Copyright (c) 2010, 2013, 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


  31 import javafx.stage.Stage;
  32 
  33 
  34 public class StagePeerListener extends WindowPeerListener {
  35     private final Stage stage;
  36     private final StageAccessor stageAccessor;
  37     private AccessibleStage accessibleController ;
  38 
  39     private static boolean ACCESSIBILITY_ENABLED = AccessController.doPrivileged(
  40         new PrivilegedAction<Boolean>() {
  41             @Override public Boolean run() {
  42                 return Boolean.getBoolean("com.sun.javafx.accessibility.enabled");
  43             }
  44         });
  45     
  46     public static interface StageAccessor {
  47         public void setIconified(Stage stage, boolean iconified);
  48         public void setMaximized(Stage stage, boolean maximized);
  49         public void setResizable(Stage stage, boolean resizable);
  50         public void setFullScreen(Stage stage, boolean fs);

  51     }
  52 
  53     public StagePeerListener(Stage stage, StageAccessor stageAccessor) {
  54         super(stage);
  55         this.stage = stage;
  56         this.stageAccessor = stageAccessor;
  57     }
  58 
  59 
  60     @Override
  61     public void changedIconified(boolean iconified) {
  62         stageAccessor.setIconified(stage, iconified);
  63     }
  64 
  65     @Override
  66     public void changedMaximized(boolean maximized) {
  67         stageAccessor.setMaximized(stage, maximized);
  68     }
  69 
  70     @Override
  71     public void changedResizable(boolean resizable) {
  72         stageAccessor.setResizable(stage, resizable);
  73     }
  74 
  75     @Override
  76     public void changedFullscreen(boolean fs) {
  77         stageAccessor.setFullScreen(stage, fs);
  78     }






  79 
  80     /**
  81      * Initialize accessibility
  82      */
  83     @Override 
  84     public void initAccessibleTKStageListener() {
  85         // For 8.0 release accessibility is not enabled by default. 
  86         if (ACCESSIBILITY_ENABLED) {
  87             accessibleController = new AccessibleStage(stage);
  88             stage.impl_getPeer().setAccessibilityInitIsComplete(accessibleController.getStageAccessible());
  89         }
  90     }
  91 
  92 }
   1 /*
   2  * Copyright (c) 2010, 2014, 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


  31 import javafx.stage.Stage;
  32 
  33 
  34 public class StagePeerListener extends WindowPeerListener {
  35     private final Stage stage;
  36     private final StageAccessor stageAccessor;
  37     private AccessibleStage accessibleController ;
  38 
  39     private static boolean ACCESSIBILITY_ENABLED = AccessController.doPrivileged(
  40         new PrivilegedAction<Boolean>() {
  41             @Override public Boolean run() {
  42                 return Boolean.getBoolean("com.sun.javafx.accessibility.enabled");
  43             }
  44         });
  45     
  46     public static interface StageAccessor {
  47         public void setIconified(Stage stage, boolean iconified);
  48         public void setMaximized(Stage stage, boolean maximized);
  49         public void setResizable(Stage stage, boolean resizable);
  50         public void setFullScreen(Stage stage, boolean fs);
  51         public void setAlwaysOnTop(Stage stage, boolean aot);
  52     }
  53 
  54     public StagePeerListener(Stage stage, StageAccessor stageAccessor) {
  55         super(stage);
  56         this.stage = stage;
  57         this.stageAccessor = stageAccessor;
  58     }
  59 
  60 
  61     @Override
  62     public void changedIconified(boolean iconified) {
  63         stageAccessor.setIconified(stage, iconified);
  64     }
  65 
  66     @Override
  67     public void changedMaximized(boolean maximized) {
  68         stageAccessor.setMaximized(stage, maximized);
  69     }
  70 
  71     @Override
  72     public void changedResizable(boolean resizable) {
  73         stageAccessor.setResizable(stage, resizable);
  74     }
  75 
  76     @Override
  77     public void changedFullscreen(boolean fs) {
  78         stageAccessor.setFullScreen(stage, fs);
  79     }
  80 
  81     @Override
  82     public void changedAlwaysOnTop(boolean aot) {
  83         stageAccessor.setAlwaysOnTop(stage, aot);
  84     }
  85     
  86 
  87     /**
  88      * Initialize accessibility
  89      */
  90     @Override 
  91     public void initAccessibleTKStageListener() {
  92         // For 8.0 release accessibility is not enabled by default. 
  93         if (ACCESSIBILITY_ENABLED) {
  94             accessibleController = new AccessibleStage(stage);
  95             stage.impl_getPeer().setAccessibilityInitIsComplete(accessibleController.getStageAccessible());
  96         }
  97     }
  98 
  99 }