< prev index next >

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

Print this page




  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     }


 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 }


  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     WDialogPeer(Dialog target) {
  41         super(target);
  42 
  43         InputMethodManager imm = InputMethodManager.getInstance();
  44         String menuString = imm.getTriggerMenuString();
  45         if (menuString != null)
  46         {
  47             pSetIMMOption(menuString);
  48         }
  49     }
  50 
  51     native void createAwtDialog(WComponentPeer parent);
  52     @Override
  53     void create(WComponentPeer parent) {
  54         preCreate(parent);
  55         createAwtDialog(parent);
  56     }
  57 
  58     native void showModal();
  59     native void endModal();
  60 
  61     @Override
  62     void initialize() {
  63         Dialog target = (Dialog)this.target;
  64         // Need to set target's background to default _before_ a call
  65         // to super.initialize.
  66         if (!target.isBackgroundSet()) {
  67             target.setBackground(defaultBackground);
  68         }
  69 
  70         super.initialize();
  71 
  72         if (target.getTitle() != null) {
  73             setTitle(target.getTitle());
  74         }
  75         setResizable(target.isResizable());
  76     }
  77 
  78     @Override
  79     protected void realShow() {
  80         Dialog dlg = (Dialog)target;
  81         if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) {
  82             showModal();
  83         } else {
  84             super.realShow();
  85         }
  86     }


 112             return super.getMinimumSize();
 113         } else {
 114             return new Dimension(getSysMinWidth(), getSysMinHeight());
 115         }
 116     }
 117 
 118     @Override
 119     boolean isTargetUndecorated() {
 120         return ((Dialog)target).isUndecorated();
 121     }
 122 
 123     @Override
 124     public void reshape(int x, int y, int width, int height) {
 125         if (((Dialog)target).isUndecorated()) {
 126             super.reshape(x, y, width, height);
 127         } else {
 128             reshapeFrame(x, y, width, height);
 129         }
 130     }
 131    













 132     native void pSetIMMOption(String option);
 133     void notifyIMMOptionChange(){
 134       InputMethodManager.getInstance().notifyChangeRequest((Component)target);
 135     }
 136 }
< prev index next >