< prev index next >

modules/graphics/src/main/java/com/sun/glass/ui/Window.java

Print this page


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


 277         }
 278     }
 279 
 280     protected abstract long _createChildWindow(long parent);
 281     /**
 282      * Constructs a child window of the specified native parent window.
 283      */
 284     protected Window(long parent) {
 285         Application.checkEventThread();
 286         this.owner = null;
 287         this.parent = parent;
 288         this.styleMask = Window.UNTITLED;
 289         this.isDecorated = false;
 290 
 291         // Note: we can't always catch screen changes when parent is moved...
 292         this.screen = null; // should infer from the parent
 293 
 294         this.ptr = _createChildWindow(parent);
 295         if (this.ptr == 0L) {
 296             throw new RuntimeException("could not create platform window");



 297         }
 298     }
 299 
 300     public boolean isClosed() {
 301         Application.checkEventThread();
 302         return this.ptr == 0L;
 303     }
 304 
 305     private void checkNotClosed() {
 306         if (this.ptr == 0L) {
 307             throw new IllegalStateException("The window has already been closed");
 308         }
 309     }
 310 
 311     protected abstract boolean _close(long ptr);
 312     public void close() {
 313         Application.checkEventThread();
 314         if (this.view != null) {
 315             if (this.ptr != 0L) {
 316                 _setView(this.ptr, null);


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


 277         }
 278     }
 279 
 280     protected abstract long _createChildWindow(long parent);
 281     /**
 282      * Constructs a child window of the specified native parent window.
 283      */
 284     protected Window(long parent) {
 285         Application.checkEventThread();
 286         this.owner = null;
 287         this.parent = parent;
 288         this.styleMask = Window.UNTITLED;
 289         this.isDecorated = false;
 290 
 291         // Note: we can't always catch screen changes when parent is moved...
 292         this.screen = null; // should infer from the parent
 293 
 294         this.ptr = _createChildWindow(parent);
 295         if (this.ptr == 0L) {
 296             throw new RuntimeException("could not create platform window");
 297         }
 298         if (screen == null) {
 299             screen = Screen.getMainScreen(); // start with a default
 300         }
 301     }
 302 
 303     public boolean isClosed() {
 304         Application.checkEventThread();
 305         return this.ptr == 0L;
 306     }
 307 
 308     private void checkNotClosed() {
 309         if (this.ptr == 0L) {
 310             throw new IllegalStateException("The window has already been closed");
 311         }
 312     }
 313 
 314     protected abstract boolean _close(long ptr);
 315     public void close() {
 316         Application.checkEventThread();
 317         if (this.view != null) {
 318             if (this.ptr != 0L) {
 319                 _setView(this.ptr, null);


< prev index next >