965
1002
return desktopPropsSupport.getPropertyChangeListeners(name);
1006
* Adds an AWTEventListener to this toolkit. This listener is informed about
1007
* all events that pass the eventqueue that match the specified
1008
* <code>evenMask</code>. The <code>eventMask</code> is an ORed combination
1009
* of event masks as defined in {@link AWTEvent}.
1011
* If a security manager is installed, it is asked first if an
1012
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
1013
* This may result in a <code>SecurityException</code> beeing thrown.
1015
* It is not recommended to use this kind of notification for normal
1016
* applications. It is intended solely for the purpose of debugging and to
1017
* support special facilities.
1019
* @param listener the listener to add
1020
* @param eventMask the event mask of event types which the listener is
1025
* @throws SecurityException if there is a <code>SecurityManager</code> that
1027
* <code>AWTPermission("listenToAllAWTEvents")</code>
1029
* @see #getAWTEventListeners()
1030
* @see #getAWTEventListeners(long)
1031
* @see #removeAWTEventListener(AWTEventListener)
968
1033
public void addAWTEventListener(AWTEventListener listener, long eventMask)
970
// SecurityManager s = System.getSecurityManager();
972
// s.checkPermission(AWTPermission("listenToAllAWTEvents"));
1035
// First we must check the security permissions.
1036
SecurityManager s = System.getSecurityManager();
1038
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
1040
// Go through the list and check if the requested listener is already
1042
boolean found = false;
1043
for (int i = 0; i < awtEventListeners.length; ++i)
1045
AWTEventListenerProxy proxy = awtEventListeners[i];
1046
if (proxy.getListener() == listener)
1049
// Modify the proxies event mask to include the new event mask.
1050
AWTEventListenerProxy newProxy =
1051
new AWTEventListenerProxy(proxy.getEventMask() | eventMask,
1053
awtEventListeners[i] = newProxy;
1058
// If that listener was not found, then add it.
1061
AWTEventListenerProxy proxy =
1062
new AWTEventListenerProxy(eventMask, listener);
1063
AWTEventListenerProxy[] newArray =
1064
new AWTEventListenerProxy[awtEventListeners.length + 1];
1065
System.arraycopy(awtEventListeners, 0, newArray, 0,
1066
awtEventListeners.length);
1067
newArray[newArray.length - 1] = proxy;
1068
awtEventListeners = newArray;
1073
* Removes an AWT event listener from this toolkit. This listener is no
1074
* longer informed of any event types it was registered in.
1076
* If a security manager is installed, it is asked first if an
1077
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
1078
* This may result in a <code>SecurityException</code> beeing thrown.
1080
* It is not recommended to use this kind of notification for normal
1081
* applications. It is intended solely for the purpose of debugging and to
1082
* support special facilities.
1084
* @param listener the listener to remove
1086
* @throws SecurityException if there is a <code>SecurityManager</code> that
1088
* <code>AWTPermission("listenToAllAWTEvents")</code>
1092
* @see #addAWTEventListener(AWTEventListener, long)
1093
* @see #getAWTEventListeners()
1094
* @see #getAWTEventListeners(long)
976
1096
public void removeAWTEventListener(AWTEventListener listener)
1098
// First we must check the security permissions.
1099
SecurityManager s = System.getSecurityManager();
1101
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
1104
// Find the index of the listener.
1106
for (int i = 0; i < awtEventListeners.length; ++i)
1108
AWTEventListenerProxy proxy = awtEventListeners[i];
1109
if (proxy.getListener() == listener)
1116
// Copy over the arrays and leave out the removed element.
1119
AWTEventListenerProxy[] newArray =
1120
new AWTEventListenerProxy[awtEventListeners.length - 1];
1122
System.arraycopy(awtEventListeners, 0, newArray, 0, index);
1123
if (index < awtEventListeners.length - 1)
1124
System.arraycopy(awtEventListeners, index + 1, newArray, index,
1125
awtEventListeners.length - index - 1);
1126
awtEventListeners = newArray;
1131
* Returns all registered AWT event listeners. This method returns a copy of
1132
* the listener array, so that application cannot trash the listener list.
1134
* If a security manager is installed, it is asked first if an
1135
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
1136
* This may result in a <code>SecurityException</code> beeing thrown.
1138
* It is not recommended to use this kind of notification for normal
1139
* applications. It is intended solely for the purpose of debugging and to
1140
* support special facilities.
1142
* @return all registered AWT event listeners
1144
* @throws SecurityException if there is a <code>SecurityManager</code> that
1146
* <code>AWTPermission("listenToAllAWTEvents")</code>
1150
* @see #addAWTEventListener(AWTEventListener, long)
1151
* @see #removeAWTEventListener(AWTEventListener)
1152
* @see #getAWTEventListeners(long)
984
1154
public AWTEventListener[] getAWTEventListeners()
1156
// First we must check the security permissions.
1157
SecurityManager s = System.getSecurityManager();
1159
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
1161
// Create a copy of the array.
1162
AWTEventListener[] copy = new AWTEventListener[awtEventListeners.length];
1163
System.arraycopy(awtEventListeners, 0, copy, 0, awtEventListeners.length);
1168
* Returns all registered AWT event listeners that listen for events with
1169
* the specified <code>eventMask</code>. This method returns a copy of
1170
* the listener array, so that application cannot trash the listener list.
1172
* If a security manager is installed, it is asked first if an
1173
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
1174
* This may result in a <code>SecurityException</code> beeing thrown.
1176
* It is not recommended to use this kind of notification for normal
1177
* applications. It is intended solely for the purpose of debugging and to
1178
* support special facilities.
1180
* @param mask the event mask
1182
* @throws SecurityException if there is a <code>SecurityManager</code> that
1184
* <code>AWTPermission("listenToAllAWTEvents")</code>
1189
* @see #addAWTEventListener(AWTEventListener, long)
1190
* @see #removeAWTEventListener(AWTEventListener)
1191
* @see #getAWTEventListeners()
992
1193
public AWTEventListener[] getAWTEventListeners(long mask)
1195
// First we must check the security permissions.
1196
SecurityManager s = System.getSecurityManager();
1198
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
1200
// Create a copy of the array with only the requested listeners in it.
1201
ArrayList l = new ArrayList(awtEventListeners.length);
1202
for (int i = 0; i < awtEventListeners.length; ++i)
1204
if ((awtEventListeners[i].getEventMask() & mask) != 0)
1205
l.add(awtEventListeners[i]);
1208
return (AWTEventListener[] ) l.toArray(new AWTEventListener[l.size()]);
1213
* Dispatches events to listeners registered to this Toolkit. This is called
1214
* by {@link Component#dispatchEventImpl(AWTEvent)} in order to dispatch
1217
* @param ev the event to dispatch
1219
void globalDispatchEvent(AWTEvent ev)
1221
// We do not use the accessor methods here because they create new
1222
// arrays each time. We must be very efficient, so we access this directly.
1223
for (int i = 0; i < awtEventListeners.length; ++i)
1225
AWTEventListenerProxy proxy = awtEventListeners[i];
1226
if ((proxy.getEventMask() & AWTEvent.eventIdToMask(ev.getID())) != 0)
1227
proxy.eventDispatched(ev);
1000
1234
public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight);
1237
* Initializes the accessibility framework. In particular, this loads the
1238
* properties javax.accessibility.screen_magnifier_present and
1239
* javax.accessibility.screen_reader_present and loads
1240
* the classes specified in javax.accessibility.assistive_technologies.
1242
private static void initAccessibility()
1244
AccessController.doPrivileged
1245
(new PrivilegedAction()
1249
Properties props = new Properties();
1250
String sep = File.separator;
1252
// Try the user configuration.
1255
File propsFile = new File(System.getProperty("user.home") + sep
1256
+ ".accessibility.properties");
1257
FileInputStream in = new FileInputStream(propsFile);
1261
catch (Exception ex)
1263
// User configuration not present, ignore.
1266
// Try the system configuration if there was no user configuration.
1267
if (props.size() == 0)
1272
new File(System.getProperty("gnu.classpath.home.url")
1273
+ sep + "accessibility.properties");
1274
FileInputStream in = new FileInputStream(propsFile);
1278
catch (Exception ex)
1280
// System configuration not present, ignore.
1284
// Fetch the screen_magnifier_present property. Check systen properties
1285
// first, then fallback to the configuration file.
1286
String magPresent = SystemProperties.getProperty
1287
("javax.accessibility.screen_magnifier_present");
1288
if (magPresent == null)
1290
magPresent = props.getProperty("screen_magnifier_present");
1291
if (magPresent != null)
1293
SystemProperties.setProperty
1294
("javax.accessibility.screen_magnifier_present", magPresent);
1298
// Fetch the screen_reader_present property. Check systen properties
1299
// first, then fallback to the configuration file.
1300
String readerPresent = SystemProperties.getProperty
1301
("javax.accessibility.screen_reader_present");
1302
if (readerPresent == null)
1304
readerPresent = props.getProperty("screen_reader_present");
1305
if (readerPresent != null)
1307
SystemProperties.setProperty
1308
("javax.accessibility.screen_reader_present", readerPresent);
1312
// Fetch the list of classes to be loaded.
1313
String classes = SystemProperties.getProperty
1314
("javax.accessibility.assistive_technologies");
1315
if (classes == null)
1317
classes = props.getProperty("assistive_technologies");
1318
if (classes != null)
1320
SystemProperties.setProperty
1321
("javax.accessibility.assistive_technologies", classes);
1325
// Try to load the assisitive_technologies classes.
1326
if (classes != null)
1328
ClassLoader cl = ClassLoader.getSystemClassLoader();
1329
StringTokenizer tokenizer = new StringTokenizer(classes, ",");
1330
while (tokenizer.hasMoreTokens())
1332
String className = tokenizer.nextToken();
1335
Class atClass = cl.loadClass(className);
1336
atClass.newInstance();
1338
catch (ClassNotFoundException ex)
1340
AWTError err = new AWTError("Assistive Technology class not"
1341
+ " found: " + className);
1345
catch (InstantiationException ex)
1348
new AWTError("Assistive Technology class cannot be "
1349
+ "instantiated: " + className);
1353
catch (IllegalAccessException ex)
1356
new AWTError("Assistive Technology class cannot be "
1357
+ "accessed: " + className);
1001
1369
} // class Toolkit