2
|
1 |
/*
|
|
2 |
* Copyright 2005-2007 Sun Microsystems, Inc. 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. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package java.awt;
|
|
27 |
|
|
28 |
import java.util.Vector;
|
|
29 |
import java.awt.peer.SystemTrayPeer;
|
|
30 |
import java.beans.PropertyChangeListener;
|
|
31 |
import java.beans.PropertyChangeSupport;
|
|
32 |
import sun.awt.AppContext;
|
|
33 |
import sun.awt.SunToolkit;
|
|
34 |
import sun.awt.HeadlessToolkit;
|
|
35 |
import sun.security.util.SecurityConstants;
|
|
36 |
|
|
37 |
/**
|
|
38 |
* The <code>SystemTray</code> class represents the system tray for a
|
|
39 |
* desktop. On Microsoft Windows it is referred to as the "Taskbar
|
|
40 |
* Status Area", on Gnome it is referred to as the "Notification
|
|
41 |
* Area", on KDE it is referred to as the "System Tray". The system
|
|
42 |
* tray is shared by all applications running on the desktop.
|
|
43 |
*
|
|
44 |
* <p> On some platforms the system tray may not be present or may not
|
|
45 |
* be supported, in this case {@link SystemTray#getSystemTray()}
|
|
46 |
* throws {@link UnsupportedOperationException}. To detect whether the
|
|
47 |
* system tray is supported, use {@link SystemTray#isSupported}.
|
|
48 |
*
|
|
49 |
* <p>The <code>SystemTray</code> may contain one or more {@link
|
|
50 |
* TrayIcon TrayIcons}, which are added to the tray using the {@link
|
|
51 |
* #add} method, and removed when no longer needed, using the
|
|
52 |
* {@link #remove}. <code>TrayIcon</code> consists of an
|
|
53 |
* image, a popup menu and a set of associated listeners. Please see
|
|
54 |
* the {@link TrayIcon} class for details.
|
|
55 |
*
|
|
56 |
* <p>Every Java application has a single <code>SystemTray</code>
|
|
57 |
* instance that allows the app to interface with the system tray of
|
|
58 |
* the desktop while the app is running. The <code>SystemTray</code>
|
|
59 |
* instance can be obtained from the {@link #getSystemTray} method.
|
|
60 |
* An application may not create its own instance of
|
|
61 |
* <code>SystemTray</code>.
|
|
62 |
*
|
|
63 |
* <p>The following code snippet demonstrates how to access
|
|
64 |
* and customize the system tray:
|
|
65 |
* <code>
|
|
66 |
* <pre>
|
|
67 |
* {@link TrayIcon} trayIcon = null;
|
|
68 |
* if (SystemTray.isSupported()) {
|
|
69 |
* // get the SystemTray instance
|
|
70 |
* SystemTray tray = SystemTray.{@link #getSystemTray};
|
|
71 |
* // load an image
|
|
72 |
* {@link java.awt.Image} image = {@link java.awt.Toolkit#getImage(String) Toolkit.getDefaultToolkit().getImage}(...);
|
|
73 |
* // create a action listener to listen for default action executed on the tray icon
|
|
74 |
* {@link java.awt.event.ActionListener} listener = new {@link java.awt.event.ActionListener ActionListener}() {
|
|
75 |
* public void {@link java.awt.event.ActionListener#actionPerformed actionPerformed}({@link java.awt.event.ActionEvent} e) {
|
|
76 |
* // execute default action of the application
|
|
77 |
* // ...
|
|
78 |
* }
|
|
79 |
* };
|
|
80 |
* // create a popup menu
|
|
81 |
* {@link java.awt.PopupMenu} popup = new {@link java.awt.PopupMenu#PopupMenu PopupMenu}();
|
|
82 |
* // create menu item for the default action
|
|
83 |
* MenuItem defaultItem = new MenuItem(...);
|
|
84 |
* defaultItem.addActionListener(listener);
|
|
85 |
* popup.add(defaultItem);
|
|
86 |
* /// ... add other items
|
|
87 |
* // construct a TrayIcon
|
|
88 |
* trayIcon = new {@link TrayIcon#TrayIcon(java.awt.Image, String, java.awt.PopupMenu) TrayIcon}(image, "Tray Demo", popup);
|
|
89 |
* // set the TrayIcon properties
|
|
90 |
* trayIcon.{@link TrayIcon#addActionListener(java.awt.event.ActionListener) addActionListener}(listener);
|
|
91 |
* // ...
|
|
92 |
* // add the tray image
|
|
93 |
* try {
|
|
94 |
* tray.{@link SystemTray#add(TrayIcon) add}(trayIcon);
|
|
95 |
* } catch (AWTException e) {
|
|
96 |
* System.err.println(e);
|
|
97 |
* }
|
|
98 |
* // ...
|
|
99 |
* } else {
|
|
100 |
* // disable tray option in your application or
|
|
101 |
* // perform other actions
|
|
102 |
* ...
|
|
103 |
* }
|
|
104 |
* // ...
|
|
105 |
* // some time later
|
|
106 |
* // the application state has changed - update the image
|
|
107 |
* if (trayIcon != null) {
|
|
108 |
* trayIcon.{@link TrayIcon#setImage(java.awt.Image) setImage}(updatedImage);
|
|
109 |
* }
|
|
110 |
* // ...
|
|
111 |
* </pre>
|
|
112 |
* </code>
|
|
113 |
*
|
|
114 |
* @since 1.6
|
|
115 |
* @see TrayIcon
|
|
116 |
*
|
|
117 |
* @author Bino George
|
|
118 |
* @author Denis Mikhalkin
|
|
119 |
* @author Sharon Zakhour
|
|
120 |
* @author Anton Tarasov
|
|
121 |
*/
|
|
122 |
public class SystemTray {
|
|
123 |
private static SystemTray systemTray;
|
|
124 |
private int currentIconID = 0; // each TrayIcon added gets a unique ID
|
|
125 |
|
|
126 |
transient private SystemTrayPeer peer;
|
|
127 |
|
1168
|
128 |
private static final TrayIcon[] EMPTY_TRAY_ARRAY = new TrayIcon[0];
|
|
129 |
|
2
|
130 |
/**
|
|
131 |
* Private <code>SystemTray</code> constructor.
|
|
132 |
*
|
|
133 |
*/
|
|
134 |
private SystemTray() {
|
|
135 |
addNotify();
|
|
136 |
}
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Gets the <code>SystemTray</code> instance that represents the
|
|
140 |
* desktop's tray area. This always returns the same instance per
|
|
141 |
* application. On some platforms the system tray may not be
|
|
142 |
* supported. You may use the {@link #isSupported} method to
|
|
143 |
* check if the system tray is supported.
|
|
144 |
*
|
|
145 |
* <p>If a SecurityManager is installed, the AWTPermission
|
|
146 |
* {@code accessSystemTray} must be granted in order to get the
|
|
147 |
* {@code SystemTray} instance. Otherwise this method will throw a
|
|
148 |
* SecurityException.
|
|
149 |
*
|
|
150 |
* @return the <code>SystemTray</code> instance that represents
|
|
151 |
* the desktop's tray area
|
|
152 |
* @throws UnsupportedOperationException if the system tray isn't
|
|
153 |
* supported by the current platform
|
|
154 |
* @throws HeadlessException if
|
|
155 |
* <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
|
|
156 |
* @throws SecurityException if {@code accessSystemTray} permission
|
|
157 |
* is not granted
|
|
158 |
* @see #add(TrayIcon)
|
|
159 |
* @see TrayIcon
|
|
160 |
* @see #isSupported
|
|
161 |
* @see SecurityManager#checkPermission
|
|
162 |
* @see AWTPermission
|
|
163 |
*/
|
|
164 |
public static SystemTray getSystemTray() {
|
|
165 |
checkSystemTrayAllowed();
|
|
166 |
if (GraphicsEnvironment.isHeadless()) {
|
|
167 |
throw new HeadlessException();
|
|
168 |
}
|
|
169 |
|
|
170 |
initializeSystemTrayIfNeeded();
|
|
171 |
|
|
172 |
if (!isSupported()) {
|
|
173 |
throw new UnsupportedOperationException(
|
|
174 |
"The system tray is not supported on the current platform.");
|
|
175 |
}
|
|
176 |
|
|
177 |
return systemTray;
|
|
178 |
}
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Returns whether the system tray is supported on the current
|
|
182 |
* platform. In addition to displaying the tray icon, minimal
|
|
183 |
* system tray support includes either a popup menu (see {@link
|
|
184 |
* TrayIcon#setPopupMenu(PopupMenu)}) or an action event (see
|
|
185 |
* {@link TrayIcon#addActionListener(ActionListener)}).
|
|
186 |
*
|
|
187 |
* <p>Developers should not assume that all of the system tray
|
|
188 |
* functionality is supported. To guarantee that the tray icon's
|
|
189 |
* default action is always accessible, add the default action to
|
|
190 |
* both the action listener and the popup menu. See the {@link
|
|
191 |
* SystemTray example} for an example of how to do this.
|
|
192 |
*
|
|
193 |
* <p><b>Note</b>: When implementing <code>SystemTray</code> and
|
|
194 |
* <code>TrayIcon</code> it is <em>strongly recommended</em> that
|
|
195 |
* you assign different gestures to the popup menu and an action
|
|
196 |
* event. Overloading a gesture for both purposes is confusing
|
|
197 |
* and may prevent the user from accessing one or the other.
|
|
198 |
*
|
|
199 |
* @see #getSystemTray
|
|
200 |
* @return <code>false</code> if no system tray access is supported; this
|
|
201 |
* method returns <code>true</code> if the minimal system tray access is
|
|
202 |
* supported but does not guarantee that all system tray
|
|
203 |
* functionality is supported for the current platform
|
|
204 |
*/
|
|
205 |
public static boolean isSupported() {
|
|
206 |
initializeSystemTrayIfNeeded();
|
|
207 |
|
1168
|
208 |
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
2
|
209 |
|
1168
|
210 |
if (toolkit instanceof SunToolkit) {
|
|
211 |
return ((SunToolkit)toolkit).isTraySupported();
|
|
212 |
} else if (toolkit instanceof HeadlessToolkit) {
|
|
213 |
return ((HeadlessToolkit)toolkit).isTraySupported();
|
2
|
214 |
}
|
|
215 |
return false;
|
|
216 |
}
|
|
217 |
|
|
218 |
/**
|
|
219 |
* Adds a <code>TrayIcon</code> to the <code>SystemTray</code>.
|
|
220 |
* The tray icon becomes visible in the system tray once it is
|
|
221 |
* added. The order in which icons are displayed in a tray is not
|
|
222 |
* specified - it is platform and implementation-dependent.
|
|
223 |
*
|
|
224 |
* <p> All icons added by the application are automatically
|
|
225 |
* removed from the <code>SystemTray</code> upon application exit
|
|
226 |
* and also when the desktop system tray becomes unavailable.
|
|
227 |
*
|
|
228 |
* @param trayIcon the <code>TrayIcon</code> to be added
|
|
229 |
* @throws NullPointerException if <code>trayIcon</code> is
|
|
230 |
* <code>null</code>
|
|
231 |
* @throws IllegalArgumentException if the same instance of
|
|
232 |
* a <code>TrayIcon</code> is added more than once
|
|
233 |
* @throws AWTException if the desktop system tray is missing
|
|
234 |
* @see #remove(TrayIcon)
|
|
235 |
* @see #getSystemTray
|
|
236 |
* @see TrayIcon
|
|
237 |
* @see java.awt.Image
|
|
238 |
*/
|
|
239 |
public void add(TrayIcon trayIcon) throws AWTException {
|
|
240 |
if (trayIcon == null) {
|
|
241 |
throw new NullPointerException("adding null TrayIcon");
|
|
242 |
}
|
|
243 |
TrayIcon[] oldArray = null, newArray = null;
|
|
244 |
Vector<TrayIcon> icons = null;
|
|
245 |
synchronized (this) {
|
|
246 |
oldArray = systemTray.getTrayIcons();
|
|
247 |
icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
|
|
248 |
if (icons == null) {
|
|
249 |
icons = new Vector<TrayIcon>(3);
|
|
250 |
AppContext.getAppContext().put(TrayIcon.class, icons);
|
|
251 |
|
|
252 |
} else if (icons.contains(trayIcon)) {
|
|
253 |
throw new IllegalArgumentException("adding TrayIcon that is already added");
|
|
254 |
}
|
|
255 |
icons.add(trayIcon);
|
|
256 |
newArray = systemTray.getTrayIcons();
|
|
257 |
|
|
258 |
trayIcon.setID(++currentIconID);
|
|
259 |
}
|
|
260 |
try {
|
|
261 |
trayIcon.addNotify();
|
|
262 |
} catch (AWTException e) {
|
|
263 |
icons.remove(trayIcon);
|
|
264 |
throw e;
|
|
265 |
}
|
|
266 |
firePropertyChange("trayIcons", oldArray, newArray);
|
|
267 |
}
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Removes the specified <code>TrayIcon</code> from the
|
|
271 |
* <code>SystemTray</code>.
|
|
272 |
*
|
|
273 |
* <p> All icons added by the application are automatically
|
|
274 |
* removed from the <code>SystemTray</code> upon application exit
|
|
275 |
* and also when the desktop system tray becomes unavailable.
|
|
276 |
*
|
|
277 |
* <p> If <code>trayIcon</code> is <code>null</code> or was not
|
|
278 |
* added to the system tray, no exception is thrown and no action
|
|
279 |
* is performed.
|
|
280 |
*
|
|
281 |
* @param trayIcon the <code>TrayIcon</code> to be removed
|
|
282 |
* @see #add(TrayIcon)
|
|
283 |
* @see TrayIcon
|
|
284 |
*/
|
|
285 |
public void remove(TrayIcon trayIcon) {
|
|
286 |
if (trayIcon == null) {
|
|
287 |
return;
|
|
288 |
}
|
|
289 |
TrayIcon[] oldArray = null, newArray = null;
|
|
290 |
synchronized (this) {
|
|
291 |
oldArray = systemTray.getTrayIcons();
|
|
292 |
Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
|
|
293 |
// TrayIcon with no peer is not contained in the array.
|
|
294 |
if (icons == null || !icons.remove(trayIcon)) {
|
|
295 |
return;
|
|
296 |
}
|
|
297 |
trayIcon.removeNotify();
|
|
298 |
newArray = systemTray.getTrayIcons();
|
|
299 |
}
|
|
300 |
firePropertyChange("trayIcons", oldArray, newArray);
|
|
301 |
}
|
|
302 |
|
|
303 |
/**
|
|
304 |
* Returns an array of all icons added to the tray by this
|
|
305 |
* application. You can't access the icons added by another
|
|
306 |
* application. Some browsers partition applets in different
|
|
307 |
* code bases into separate contexts, and establish walls between
|
|
308 |
* these contexts. In such a scenario, only the tray icons added
|
|
309 |
* from this context will be returned.
|
|
310 |
*
|
|
311 |
* <p> The returned array is a copy of the actual array and may be
|
|
312 |
* modified in any way without affecting the system tray. To
|
|
313 |
* remove a <code>TrayIcon</code> from the
|
|
314 |
* <code>SystemTray</code>, use the {@link
|
|
315 |
* #remove(TrayIcon)} method.
|
|
316 |
*
|
|
317 |
* @return an array of all tray icons added to this tray, or an
|
|
318 |
* empty array if none has been added
|
|
319 |
* @see #add(TrayIcon)
|
|
320 |
* @see TrayIcon
|
|
321 |
*/
|
|
322 |
public TrayIcon[] getTrayIcons() {
|
|
323 |
Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
|
|
324 |
if (icons != null) {
|
|
325 |
return (TrayIcon[])icons.toArray(new TrayIcon[icons.size()]);
|
|
326 |
}
|
1168
|
327 |
return EMPTY_TRAY_ARRAY;
|
2
|
328 |
}
|
|
329 |
|
|
330 |
/**
|
|
331 |
* Returns the size, in pixels, of the space that a tray icon will
|
|
332 |
* occupy in the system tray. Developers may use this methods to
|
|
333 |
* acquire the preferred size for the image property of a tray icon
|
|
334 |
* before it is created. For convenience, there is a similar
|
|
335 |
* method {@link TrayIcon#getSize} in the <code>TrayIcon</code> class.
|
|
336 |
*
|
|
337 |
* @return the default size of a tray icon, in pixels
|
|
338 |
* @see TrayIcon#setImageAutoSize(boolean)
|
|
339 |
* @see java.awt.Image
|
|
340 |
* @see TrayIcon#getSize()
|
|
341 |
*/
|
|
342 |
public Dimension getTrayIconSize() {
|
|
343 |
return peer.getTrayIconSize();
|
|
344 |
}
|
|
345 |
|
|
346 |
/**
|
|
347 |
* Adds a {@code PropertyChangeListener} to the list of listeners for the
|
|
348 |
* specific property. The following properties are currently supported:
|
|
349 |
* <p> </p>
|
|
350 |
* <table border=1 summary="SystemTray properties">
|
|
351 |
* <tr>
|
|
352 |
* <th>Property</th>
|
|
353 |
* <th>Description</th>
|
|
354 |
* </tr>
|
|
355 |
* <tr>
|
|
356 |
* <td>{@code trayIcons}</td>
|
|
357 |
* <td>The {@code SystemTray}'s array of {@code TrayIcon} objects.
|
|
358 |
* The array is accessed via the {@link #getTrayIcons} method.<br>
|
|
359 |
* This property is changed when a tray icon is added to (or removed
|
|
360 |
* from) the system tray.<br> For example, this property is changed
|
|
361 |
* when the system tray becomes unavailable on the desktop<br>
|
|
362 |
* and the tray icons are automatically removed.</td>
|
|
363 |
* </tr>
|
|
364 |
* <tr>
|
|
365 |
* <td>{@code systemTray}</td>
|
|
366 |
* <td>This property contains {@code SystemTray} instance when the system tray
|
|
367 |
* is available or <code>null</code> otherwise.<br> This property is changed
|
|
368 |
* when the system tray becomes available or unavailable on the desktop.<br>
|
|
369 |
* The property is accessed by the {@link #getSystemTray} method.</td>
|
|
370 |
* </tr>
|
|
371 |
* </table>
|
|
372 |
* <p> </p>
|
|
373 |
* The {@code listener} listens to property changes only in this context.
|
|
374 |
* <p>
|
|
375 |
* If {@code listener} is {@code null}, no exception is thrown
|
|
376 |
* and no action is performed.
|
|
377 |
*
|
|
378 |
* @param propertyName the specified property
|
|
379 |
* @param listener the property change listener to be added
|
|
380 |
*
|
|
381 |
* @see #removePropertyChangeListener
|
|
382 |
* @see #getPropertyChangeListeners
|
|
383 |
*/
|
|
384 |
public synchronized void addPropertyChangeListener(String propertyName,
|
|
385 |
PropertyChangeListener listener)
|
|
386 |
{
|
|
387 |
if (listener == null) {
|
|
388 |
return;
|
|
389 |
}
|
|
390 |
getCurrentChangeSupport().addPropertyChangeListener(propertyName, listener);
|
|
391 |
}
|
|
392 |
|
|
393 |
/**
|
|
394 |
* Removes a {@code PropertyChangeListener} from the listener list
|
|
395 |
* for a specific property.
|
|
396 |
* <p>
|
|
397 |
* The {@code PropertyChangeListener} must be from this context.
|
|
398 |
* <p>
|
|
399 |
* If {@code propertyName} or {@code listener} is {@code null} or invalid,
|
|
400 |
* no exception is thrown and no action is taken.
|
|
401 |
*
|
|
402 |
* @param propertyName the specified property
|
|
403 |
* @param listener the PropertyChangeListener to be removed
|
|
404 |
*
|
|
405 |
* @see #addPropertyChangeListener
|
|
406 |
* @see #getPropertyChangeListeners
|
|
407 |
*/
|
|
408 |
public synchronized void removePropertyChangeListener(String propertyName,
|
|
409 |
PropertyChangeListener listener)
|
|
410 |
{
|
|
411 |
if (listener == null) {
|
|
412 |
return;
|
|
413 |
}
|
|
414 |
getCurrentChangeSupport().removePropertyChangeListener(propertyName, listener);
|
|
415 |
}
|
|
416 |
|
|
417 |
/**
|
|
418 |
* Returns an array of all the listeners that have been associated
|
|
419 |
* with the named property.
|
|
420 |
* <p>
|
|
421 |
* Only the listeners in this context are returned.
|
|
422 |
*
|
|
423 |
* @param propertyName the specified property
|
|
424 |
* @return all of the {@code PropertyChangeListener}s associated with
|
|
425 |
* the named property; if no such listeners have been added or
|
|
426 |
* if {@code propertyName} is {@code null} or invalid, an empty
|
|
427 |
* array is returned
|
|
428 |
*
|
|
429 |
* @see #addPropertyChangeListener
|
|
430 |
* @see #removePropertyChangeListener
|
|
431 |
*/
|
|
432 |
public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
|
|
433 |
return getCurrentChangeSupport().getPropertyChangeListeners(propertyName);
|
|
434 |
}
|
|
435 |
|
|
436 |
|
|
437 |
// ***************************************************************
|
|
438 |
// ***************************************************************
|
|
439 |
|
|
440 |
|
|
441 |
/**
|
|
442 |
* Support for reporting bound property changes for Object properties.
|
|
443 |
* This method can be called when a bound property has changed and it will
|
|
444 |
* send the appropriate PropertyChangeEvent to any registered
|
|
445 |
* PropertyChangeListeners.
|
|
446 |
*
|
|
447 |
* @param propertyName the property whose value has changed
|
|
448 |
* @param oldValue the property's previous value
|
|
449 |
* @param newValue the property's new value
|
|
450 |
*/
|
|
451 |
private void firePropertyChange(String propertyName,
|
|
452 |
Object oldValue, Object newValue)
|
|
453 |
{
|
|
454 |
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
|
455 |
return;
|
|
456 |
}
|
|
457 |
getCurrentChangeSupport().firePropertyChange(propertyName, oldValue, newValue);
|
|
458 |
}
|
|
459 |
|
|
460 |
/**
|
|
461 |
* Returns the current PropertyChangeSupport instance for the
|
|
462 |
* calling thread's context.
|
|
463 |
*
|
|
464 |
* @return this thread's context's PropertyChangeSupport
|
|
465 |
*/
|
|
466 |
private synchronized PropertyChangeSupport getCurrentChangeSupport() {
|
|
467 |
PropertyChangeSupport changeSupport =
|
|
468 |
(PropertyChangeSupport)AppContext.getAppContext().get(SystemTray.class);
|
|
469 |
|
|
470 |
if (changeSupport == null) {
|
|
471 |
changeSupport = new PropertyChangeSupport(this);
|
|
472 |
AppContext.getAppContext().put(SystemTray.class, changeSupport);
|
|
473 |
}
|
|
474 |
return changeSupport;
|
|
475 |
}
|
|
476 |
|
|
477 |
synchronized void addNotify() {
|
|
478 |
if (peer == null) {
|
|
479 |
peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createSystemTray(this);
|
|
480 |
}
|
|
481 |
}
|
|
482 |
|
|
483 |
static void checkSystemTrayAllowed() {
|
|
484 |
SecurityManager security = System.getSecurityManager();
|
|
485 |
if (security != null) {
|
|
486 |
security.checkPermission(SecurityConstants.ACCESS_SYSTEM_TRAY_PERMISSION);
|
|
487 |
}
|
|
488 |
}
|
|
489 |
|
|
490 |
private static void initializeSystemTrayIfNeeded() {
|
|
491 |
synchronized (SystemTray.class) {
|
|
492 |
if (systemTray == null) {
|
|
493 |
systemTray = new SystemTray();
|
|
494 |
}
|
|
495 |
}
|
|
496 |
}
|
|
497 |
}
|