< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WDialogPeer.java

Print this page


   1 /*
   2  * Copyright (c) 1996, 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
  23  * questions.
  24  */
  25 package sun.awt.windows;
  26 
  27 import java.awt.*;
  28 import java.awt.peer.*;
  29 
  30 import sun.awt.*;
  31 import sun.awt.im.*;
  32 
  33 final class WDialogPeer extends WWindowPeer implements DialogPeer {
  34     // Toolkit & peer internals
  35 
  36     // Platform default background for dialogs.  Gets set on target if
  37     // target has none explicitly specified.
  38     static final Color defaultBackground =  SystemColor.control;
  39 
  40     // If target doesn't have its background color set, we set its
  41     // background to platform default.
  42     boolean needDefaultBackground;
  43 
  44     WDialogPeer(Dialog target) {
  45         super(target);
  46 
  47         InputMethodManager imm = InputMethodManager.getInstance();
  48         String menuString = imm.getTriggerMenuString();
  49         if (menuString != null)
  50         {
  51             pSetIMMOption(menuString);
  52         }
  53     }
  54 
  55     native void createAwtDialog(WComponentPeer parent);
  56     @Override
  57     void create(WComponentPeer parent) {
  58         preCreate(parent);
  59         createAwtDialog(parent);
  60     }
  61 
  62     native void showModal();
  63     native void endModal();
  64 
  65     @Override
  66     void initialize() {
  67         Dialog target = (Dialog)this.target;
  68         // Need to set target's background to default _before_ a call
  69         // to super.initialize.
  70         if (needDefaultBackground) {
  71             target.setBackground(defaultBackground);
  72         }
  73 
  74         super.initialize();
  75 
  76         if (target.getTitle() != null) {
  77             setTitle(target.getTitle());
  78         }
  79         setResizable(target.isResizable());
  80     }
  81 
  82     @Override
  83     protected void realShow() {
  84         Dialog dlg = (Dialog)target;
  85         if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) {
  86             showModal();
  87         } else {
  88             super.realShow();
  89         }
  90     }
  91 
  92     @Override


 114     public Dimension getMinimumSize() {
 115         if (((Dialog)target).isUndecorated()) {
 116             return super.getMinimumSize();
 117         } else {
 118             return new Dimension(getSysMinWidth(), getSysMinHeight());
 119         }
 120     }
 121 
 122     @Override
 123     boolean isTargetUndecorated() {
 124         return ((Dialog)target).isUndecorated();
 125     }
 126 
 127     @Override
 128     public void reshape(int x, int y, int width, int height) {
 129         if (((Dialog)target).isUndecorated()) {
 130             super.reshape(x, y, width, height);
 131         } else {
 132             reshapeFrame(x, y, width, height);
 133         }
 134     }
 135 
 136     /* Native create() peeks at target's background and if it's null
 137      * calls this method to arrage for default background to be set on
 138      * target.  Can't make the check in Java, since getBackground will
 139      * return owner's background if target has none set.
 140      */
 141     private void setDefaultColor() {
 142         // Can't call target.setBackground directly, since we are
 143         // called on toolkit thread.  Can't schedule a Runnable on the
 144         // EventHandlerThread because of the race condition.  So just
 145         // set a flag and call target.setBackground in initialize.
 146         needDefaultBackground = true;
 147     }
 148 
 149     native void pSetIMMOption(String option);
 150     void notifyIMMOptionChange(){
 151       InputMethodManager.getInstance().notifyChangeRequest((Component)target);
 152     }
 153 }
   1 /*
   2  * Copyright (c) 1996, 2016, 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
  23  * questions.
  24  */
  25 package sun.awt.windows;
  26 
  27 import java.awt.*;
  28 import java.awt.peer.*;
  29 
  30 import sun.awt.*;
  31 import sun.awt.im.*;
  32 
  33 final class WDialogPeer extends WWindowPeer implements DialogPeer {
  34     // Toolkit & peer internals
  35 








  36     WDialogPeer(Dialog target) {
  37         super(target);
  38 
  39         InputMethodManager imm = InputMethodManager.getInstance();
  40         String menuString = imm.getTriggerMenuString();
  41         if (menuString != null)
  42         {
  43             pSetIMMOption(menuString);
  44         }
  45     }
  46 
  47     native void createAwtDialog(WComponentPeer parent);
  48     @Override
  49     void create(WComponentPeer parent) {
  50         preCreate(parent);
  51         createAwtDialog(parent);
  52     }
  53 
  54     native void showModal();
  55     native void endModal();
  56 
  57     @Override
  58     void initialize() {
  59         Dialog target = (Dialog)this.target;





  60     
  61         super.initialize();
  62 
  63         if (target.getTitle() != null) {
  64             setTitle(target.getTitle());
  65         }
  66         setResizable(target.isResizable());
  67     }
  68 
  69     @Override
  70     protected void realShow() {
  71         Dialog dlg = (Dialog)target;
  72         if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) {
  73             showModal();
  74         } else {
  75             super.realShow();
  76         }
  77     }
  78 
  79     @Override


 101     public Dimension getMinimumSize() {
 102         if (((Dialog)target).isUndecorated()) {
 103             return super.getMinimumSize();
 104         } else {
 105             return new Dimension(getSysMinWidth(), getSysMinHeight());
 106         }
 107     }
 108 
 109     @Override
 110     boolean isTargetUndecorated() {
 111         return ((Dialog)target).isUndecorated();
 112     }
 113 
 114     @Override
 115     public void reshape(int x, int y, int width, int height) {
 116         if (((Dialog)target).isUndecorated()) {
 117             super.reshape(x, y, width, height);
 118         } else {
 119             reshapeFrame(x, y, width, height);
 120         }













 121     }
 122 
 123     native void pSetIMMOption(String option);
 124     void notifyIMMOptionChange(){
 125       InputMethodManager.getInstance().notifyChangeRequest((Component)target);
 126     }
 127 }
< prev index next >