src/share/classes/sun/awt/SunToolkit.java

Print this page




  42 import java.net.URL;
  43 import java.security.PrivilegedAction;
  44 import java.util.*;
  45 import java.util.concurrent.TimeUnit;
  46 import java.util.concurrent.locks.Condition;
  47 import java.util.concurrent.locks.Lock;
  48 import java.util.concurrent.locks.ReentrantLock;
  49 
  50 import sun.awt.datatransfer.DataTransferer;
  51 import sun.util.logging.PlatformLogger;
  52 import sun.misc.SoftCache;
  53 import sun.font.FontDesignMetrics;
  54 import sun.awt.im.InputContext;
  55 import sun.awt.image.*;
  56 import sun.security.action.GetPropertyAction;
  57 import sun.security.action.GetBooleanAction;
  58 import java.lang.reflect.InvocationTargetException;
  59 import java.security.AccessController;
  60 
  61 public abstract class SunToolkit extends Toolkit
  62     implements WindowClosingSupport, WindowClosingListener,
  63     ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider {
  64 
  65     // 8014718: logging has been removed from SunToolkit
  66 
  67     /* Load debug settings for native code */
  68     static {
  69         if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.nativedebug"))) {
  70             DebugSettings.init();
  71         }
  72     };
  73 
  74     /**
  75      * Special mask for the UngrabEvent events, in addition to the
  76      * public masks defined in AWTEvent.  Should be used as the mask
  77      * value for Toolkit.addAWTEventListener.
  78      */
  79     public static final int GRAB_EVENT_MASK = 0x80000000;
  80 
  81     /* The key to put()/get() the PostEventQueue into/from the AppContext.
  82      */
  83     private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue";


1184                     variant = "";
1185                 }
1186             } else {
1187                 country = AccessController.doPrivileged(
1188                                 new GetPropertyAction("user.country", ""));
1189                 variant = AccessController.doPrivileged(
1190                                 new GetPropertyAction("user.variant", ""));
1191             }
1192             startupLocale = new Locale(language, country, variant);
1193         }
1194         return startupLocale;
1195     }
1196 
1197     /**
1198      * Returns the default keyboard locale of the underlying operating system
1199      */
1200     public Locale getDefaultKeyboardLocale() {
1201         return getStartupLocale();
1202     }
1203 
1204     // Support for window closing event notifications
1205     private transient WindowClosingListener windowClosingListener = null;
1206     /**
1207      * @see sun.awt.WindowClosingSupport#getWindowClosingListener
1208      */
1209     public WindowClosingListener getWindowClosingListener() {
1210         return windowClosingListener;
1211     }
1212     /**
1213      * @see sun.awt.WindowClosingSupport#setWindowClosingListener
1214      */
1215     public void setWindowClosingListener(WindowClosingListener wcl) {
1216         windowClosingListener = wcl;
1217     }
1218 
1219     /**
1220      * @see sun.awt.WindowClosingListener#windowClosingNotify
1221      */
1222     public RuntimeException windowClosingNotify(WindowEvent event) {
1223         if (windowClosingListener != null) {
1224             return windowClosingListener.windowClosingNotify(event);
1225         } else {
1226             return null;
1227         }
1228     }
1229     /**
1230      * @see sun.awt.WindowClosingListener#windowClosingDelivered
1231      */
1232     public RuntimeException windowClosingDelivered(WindowEvent event) {
1233         if (windowClosingListener != null) {
1234             return windowClosingListener.windowClosingDelivered(event);
1235         } else {
1236             return null;
1237         }
1238     }
1239 
1240     private static DefaultMouseInfoPeer mPeer = null;
1241 
1242     protected synchronized MouseInfoPeer getMouseInfoPeer() {
1243         if (mPeer == null) {
1244             mPeer = new DefaultMouseInfoPeer();
1245         }
1246         return mPeer;
1247     }
1248 
1249 
1250     /**
1251      * Returns whether default toolkit needs the support of the xembed
1252      * from embedding host(if any).
1253      * @return <code>true</code>, if XEmbed is needed, <code>false</code> otherwise
1254      */
1255     public static boolean needsXEmbed() {
1256         String noxembed = AccessController.
1257             doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false"));
1258         if ("true".equals(noxembed)) {
1259             return false;




  42 import java.net.URL;
  43 import java.security.PrivilegedAction;
  44 import java.util.*;
  45 import java.util.concurrent.TimeUnit;
  46 import java.util.concurrent.locks.Condition;
  47 import java.util.concurrent.locks.Lock;
  48 import java.util.concurrent.locks.ReentrantLock;
  49 
  50 import sun.awt.datatransfer.DataTransferer;
  51 import sun.util.logging.PlatformLogger;
  52 import sun.misc.SoftCache;
  53 import sun.font.FontDesignMetrics;
  54 import sun.awt.im.InputContext;
  55 import sun.awt.image.*;
  56 import sun.security.action.GetPropertyAction;
  57 import sun.security.action.GetBooleanAction;
  58 import java.lang.reflect.InvocationTargetException;
  59 import java.security.AccessController;
  60 
  61 public abstract class SunToolkit extends Toolkit
  62     implements ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider {

  63 
  64     // 8014718: logging has been removed from SunToolkit
  65 
  66     /* Load debug settings for native code */
  67     static {
  68         if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.nativedebug"))) {
  69             DebugSettings.init();
  70         }
  71     };
  72 
  73     /**
  74      * Special mask for the UngrabEvent events, in addition to the
  75      * public masks defined in AWTEvent.  Should be used as the mask
  76      * value for Toolkit.addAWTEventListener.
  77      */
  78     public static final int GRAB_EVENT_MASK = 0x80000000;
  79 
  80     /* The key to put()/get() the PostEventQueue into/from the AppContext.
  81      */
  82     private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue";


1183                     variant = "";
1184                 }
1185             } else {
1186                 country = AccessController.doPrivileged(
1187                                 new GetPropertyAction("user.country", ""));
1188                 variant = AccessController.doPrivileged(
1189                                 new GetPropertyAction("user.variant", ""));
1190             }
1191             startupLocale = new Locale(language, country, variant);
1192         }
1193         return startupLocale;
1194     }
1195 
1196     /**
1197      * Returns the default keyboard locale of the underlying operating system
1198      */
1199     public Locale getDefaultKeyboardLocale() {
1200         return getStartupLocale();
1201     }
1202 




































1203     private static DefaultMouseInfoPeer mPeer = null;
1204 
1205     protected synchronized MouseInfoPeer getMouseInfoPeer() {
1206         if (mPeer == null) {
1207             mPeer = new DefaultMouseInfoPeer();
1208         }
1209         return mPeer;
1210     }
1211 
1212 
1213     /**
1214      * Returns whether default toolkit needs the support of the xembed
1215      * from embedding host(if any).
1216      * @return <code>true</code>, if XEmbed is needed, <code>false</code> otherwise
1217      */
1218     public static boolean needsXEmbed() {
1219         String noxembed = AccessController.
1220             doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false"));
1221         if ("true".equals(noxembed)) {
1222             return false;