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

Print this page




  25 
  26 package sun.awt;
  27 
  28 import java.awt.*;
  29 import static java.awt.RenderingHints.*;
  30 import java.awt.dnd.*;
  31 import java.awt.dnd.peer.DragSourceContextPeer;
  32 import java.awt.peer.*;
  33 import java.awt.event.WindowEvent;
  34 import java.awt.event.KeyEvent;
  35 import java.awt.image.*;
  36 import java.awt.TrayIcon;
  37 import java.awt.SystemTray;
  38 import java.awt.event.InputEvent;
  39 import java.net.URL;
  40 import java.util.*;
  41 import java.util.concurrent.TimeUnit;
  42 import java.util.concurrent.locks.Condition;
  43 import java.util.concurrent.locks.Lock;
  44 import java.util.concurrent.locks.ReentrantLock;


  45 import sun.util.logging.PlatformLogger;
  46 import sun.misc.SoftCache;
  47 import sun.font.FontDesignMetrics;
  48 import sun.awt.im.InputContext;
  49 import sun.awt.image.*;
  50 import sun.security.action.GetPropertyAction;
  51 import sun.security.action.GetBooleanAction;
  52 import java.lang.reflect.Field;
  53 import java.lang.reflect.Method;
  54 import java.lang.reflect.Constructor;
  55 import java.lang.reflect.InvocationTargetException;
  56 import java.security.AccessController;
  57 import java.security.PrivilegedAction;
  58 import java.security.PrivilegedActionException;
  59 import java.security.PrivilegedExceptionAction;
  60 
  61 public abstract class SunToolkit extends Toolkit
  62     implements WindowClosingSupport, WindowClosingListener,
  63     ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider {
  64 


1119     }
1120 
1121     /**
1122      * Returns key modifiers used by Swing to set up a focus accelerator key stroke.
1123      */
1124     public int getFocusAcceleratorKeyMask() {
1125         return InputEvent.ALT_MASK;
1126     }
1127 
1128     /**
1129      * Tests whether specified key modifiers mask can be used to enter a printable
1130      * character. This is a default implementation of this method, which reflects
1131      * the way things work on Windows: here, pressing ctrl + alt allows user to enter
1132      * characters from the extended character set (like euro sign or math symbols)
1133      */
1134     public boolean isPrintableCharacterModifiersMask(int mods) {
1135         return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK));
1136     }
1137 
1138     /**




















1139      * Returns a new input method window, with behavior as specified in
1140      * {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}.
1141      * If the inputContext is not null, the window should return it from its
1142      * getInputContext() method. The window needs to implement
1143      * sun.awt.im.InputMethodWindow.
1144      * <p>
1145      * SunToolkit subclasses can override this method to return better input
1146      * method windows.
1147      */
1148     public Window createInputMethodWindow(String title, InputContext context) {
1149         return new sun.awt.im.SimpleInputMethodWindow(title, context);
1150     }
1151 
1152     /**
1153      * Returns whether enableInputMethods should be set to true for peered
1154      * TextComponent instances on this platform. False by default.
1155      */
1156     public boolean enableInputMethodsForTextComponent() {
1157         return false;
1158     }




  25 
  26 package sun.awt;
  27 
  28 import java.awt.*;
  29 import static java.awt.RenderingHints.*;
  30 import java.awt.dnd.*;
  31 import java.awt.dnd.peer.DragSourceContextPeer;
  32 import java.awt.peer.*;
  33 import java.awt.event.WindowEvent;
  34 import java.awt.event.KeyEvent;
  35 import java.awt.image.*;
  36 import java.awt.TrayIcon;
  37 import java.awt.SystemTray;
  38 import java.awt.event.InputEvent;
  39 import java.net.URL;
  40 import java.util.*;
  41 import java.util.concurrent.TimeUnit;
  42 import java.util.concurrent.locks.Condition;
  43 import java.util.concurrent.locks.Lock;
  44 import java.util.concurrent.locks.ReentrantLock;
  45 
  46 import sun.security.util.SecurityConstants;
  47 import sun.util.logging.PlatformLogger;
  48 import sun.misc.SoftCache;
  49 import sun.font.FontDesignMetrics;
  50 import sun.awt.im.InputContext;
  51 import sun.awt.image.*;
  52 import sun.security.action.GetPropertyAction;
  53 import sun.security.action.GetBooleanAction;
  54 import java.lang.reflect.Field;
  55 import java.lang.reflect.Method;
  56 import java.lang.reflect.Constructor;
  57 import java.lang.reflect.InvocationTargetException;
  58 import java.security.AccessController;
  59 import java.security.PrivilegedAction;
  60 import java.security.PrivilegedActionException;
  61 import java.security.PrivilegedExceptionAction;
  62 
  63 public abstract class SunToolkit extends Toolkit
  64     implements WindowClosingSupport, WindowClosingListener,
  65     ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider {
  66 


1121     }
1122 
1123     /**
1124      * Returns key modifiers used by Swing to set up a focus accelerator key stroke.
1125      */
1126     public int getFocusAcceleratorKeyMask() {
1127         return InputEvent.ALT_MASK;
1128     }
1129 
1130     /**
1131      * Tests whether specified key modifiers mask can be used to enter a printable
1132      * character. This is a default implementation of this method, which reflects
1133      * the way things work on Windows: here, pressing ctrl + alt allows user to enter
1134      * characters from the extended character set (like euro sign or math symbols)
1135      */
1136     public boolean isPrintableCharacterModifiersMask(int mods) {
1137         return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK));
1138     }
1139 
1140     /**
1141      * Returns whether popup is allowed to be shown above the task bar.
1142      * This is a default implementation of this method, which checks
1143      * corresponding security permission.
1144      */
1145     public boolean canPopupOverlapTaskBar() {
1146         boolean result = true;
1147         try {
1148             SecurityManager sm = System.getSecurityManager();
1149             if (sm != null) {
1150                 sm.checkPermission(
1151                         SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
1152             }
1153         } catch (SecurityException se) {
1154             // There is no permission to show popups over the task bar
1155             result = false;
1156         }
1157         return result;
1158     }
1159 
1160     /**
1161      * Returns a new input method window, with behavior as specified in
1162      * {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}.
1163      * If the inputContext is not null, the window should return it from its
1164      * getInputContext() method. The window needs to implement
1165      * sun.awt.im.InputMethodWindow.
1166      * <p>
1167      * SunToolkit subclasses can override this method to return better input
1168      * method windows.
1169      */
1170     public Window createInputMethodWindow(String title, InputContext context) {
1171         return new sun.awt.im.SimpleInputMethodWindow(title, context);
1172     }
1173 
1174     /**
1175      * Returns whether enableInputMethods should be set to true for peered
1176      * TextComponent instances on this platform. False by default.
1177      */
1178     public boolean enableInputMethodsForTextComponent() {
1179         return false;
1180     }