|
Préférences
Moteurs de recherche
|
||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
java.awt
|
Method Summary | |
---|---|
void |
add(TrayIcon trayIcon)
Adds a TrayIcon to the SystemTray . |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a
specific property. |
PropertyChangeListener[] |
getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners that have been associated with the named property. |
static SystemTray |
getSystemTray()
Gets the SystemTray instance that represents the
desktop's tray area. |
TrayIcon[] |
getTrayIcons()
Returns an array of all icons added to the tray by this application. |
Dimension |
getTrayIconSize()
Returns the size, in pixels, of the space that a tray icon will occupy in the system tray. |
static boolean |
isSupported()
Returns whether the system tray is supported on the current platform. |
void |
remove(TrayIcon trayIcon)
Removes the specified TrayIcon from the
SystemTray . |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list
for a specific property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SystemTray getSystemTray()
SystemTray
instance that represents the
desktop's tray area. This always returns the same instance per
application. On some platforms the system tray may not be
supported. You may use the isSupported()
method to
check if the system tray is supported.
If a SecurityManager is installed, the AWTPermission
accessSystemTray
must be granted in order to get the
SystemTray
instance. Otherwise this method will throw a
SecurityException.
SystemTray
instance that represents
the desktop's tray area
UnsupportedOperationException
- if the system tray isn't
supported by the current platform
HeadlessException
- if
GraphicsEnvironment.isHeadless()
returns true
SecurityException
- if accessSystemTray
permission
is not grantedadd(TrayIcon)
,
TrayIcon
,
isSupported()
,
SecurityManager.checkPermission(java.security.Permission)
,
AWTPermission
public static boolean isSupported()
TrayIcon.setPopupMenu(PopupMenu)
) or an action event (see
TrayIcon.addActionListener(ActionListener)
).
Developers should not assume that all of the system tray
functionality is supported. To guarantee that the tray icon's
default action is always accessible, add the default action to
both the action listener and the popup menu. See the example
for an example of how to do this.
Note: When implementing SystemTray
and
TrayIcon
it is strongly recommended that
you assign different gestures to the popup menu and an action
event. Overloading a gesture for both purposes is confusing
and may prevent the user from accessing one or the other.
false
if no system tray access is supported; this
method returns true
if the minimal system tray access is
supported but does not guarantee that all system tray
functionality is supported for the current platformgetSystemTray()
public void add(TrayIcon trayIcon) throws AWTException
TrayIcon
to the SystemTray
.
The tray icon becomes visible in the system tray once it is
added. The order in which icons are displayed in a tray is not
specified - it is platform and implementation-dependent.
All icons added by the application are automatically
removed from the SystemTray
upon application exit
and also when the desktop system tray becomes unavailable.
trayIcon
- the TrayIcon
to be added
NullPointerException
- if trayIcon
is
null
IllegalArgumentException
- if the same instance of
a TrayIcon
is added more than once
AWTException
- if the desktop system tray is missingremove(TrayIcon)
,
getSystemTray()
,
TrayIcon
,
Image
public void remove(TrayIcon trayIcon)
TrayIcon
from the
SystemTray
.
All icons added by the application are automatically
removed from the SystemTray
upon application exit
and also when the desktop system tray becomes unavailable.
If trayIcon
is null
or was not
added to the system tray, no exception is thrown and no action
is performed.
trayIcon
- the TrayIcon
to be removedadd(TrayIcon)
,
TrayIcon
public TrayIcon[] getTrayIcons()
The returned array is a copy of the actual array and may be
modified in any way without affecting the system tray. To
remove a TrayIcon
from the
SystemTray
, use the remove(TrayIcon)
method.
add(TrayIcon)
,
TrayIcon
public Dimension getTrayIconSize()
TrayIcon.getSize()
in the TrayIcon
class.
TrayIcon.setImageAutoSize(boolean)
,
Image
,
TrayIcon.getSize()
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangeListener
to the listener list for a
specific property. Currently supported property:
trayIcons
This SystemTray
's array of TrayIcon
s.
The array is accessed via getTrayIcons()
.
This property is changed when a TrayIcon
is added to
(or removed from) the SystemTray
.
For example, this property
is changed when the native SystemTray
becomes unavailable on the
desktop
and the TrayIcon
s are automatically removed.
The listener
listens to property changes only in this context.
If listener
is null
, no exception is thrown
and no action is performed.
propertyName
- the specified propertylistener
- the property change listener to be addedremovePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
,
getPropertyChangeListeners(java.lang.String)
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangeListener
from the listener list
for a specific property.
The PropertyChangeListener
must be from this context.
If propertyName
or listener
is null
or invalid,
no exception is thrown and no action is taken.
propertyName
- the specified propertylistener
- the PropertyChangeListener to be removedaddPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
,
getPropertyChangeListeners(java.lang.String)
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Only the listeners in this context are returned.
propertyName
- the specified property
PropertyChangeListener
s associated with
the named property; if no such listeners have been added or
if propertyName
is null
or invalid, an empty
array is returnedaddPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)