Java Doc for TrayIcon.java in  » 6.0-JDK-Core » AWT » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.TrayIcon

TrayIcon
public class TrayIcon (Code)
A TrayIcon object represents a tray icon that can be added to the SystemTray system tray . A TrayIcon can have a tooltip (text), an image, a popup menu, and a set of listeners associated with it.

A TrayIcon can generate various MouseEventMouseEvents and supports adding corresponding listeners to receive notification of these events. TrayIcon processes some of the events by itself. For example, by default, when the right-mouse click is performed on the TrayIcon it displays the specified popup menu. When the mouse hovers over the TrayIcon the tooltip is displayed.

Note: When the MouseEvent is dispatched to its registered listeners its component property will be set to null. (See java.awt.event.ComponentEvent.getComponent ) The source property will be set to this TrayIcon. (See java.util.EventObject.getSource )

Note: A well-behaved TrayIcon implementation will assign different gestures to showing a popup menu and selecting a tray icon.

A TrayIcon can generate an ActionEventActionEvent . On some platforms, this occurs when the user selects the tray icon using either the mouse or keyboard.

If a SecurityManager is installed, the AWTPermission accessSystemTray must be granted in order to create a TrayIcon . Otherwise the constructor will throw a SecurityException.

See the SystemTray class overview for an example on how to use the TrayIcon API.
since:
   1.6
See Also:   SystemTray.add
See Also:   java.awt.event.ComponentEvent.getComponent
See Also:   java.util.EventObject.getSource
author:
   Bino George
author:
   Denis Mikhalkin
author:
   Sharon Zakhour
author:
   Anton Tarasov


Inner Class :public enum MessageType

Field Summary
transient  ActionListeneractionListener
    
transient  MouseListenermouseListener
    
transient  MouseMotionListenermouseMotionListener
    

Constructor Summary
public  TrayIcon(Image image)
     Creates a TrayIcon with the specified image.
public  TrayIcon(Image image, String tooltip)
     Creates a TrayIcon with the specified image and tooltip text.
public  TrayIcon(Image image, String tooltip, PopupMenu popup)
     Creates a TrayIcon with the specified image, tooltip and popup menu.

Method Summary
public synchronized  voidaddActionListener(ActionListener listener)
     Adds the specified action listener to receive ActionEvents from this TrayIcon. Action events usually occur when a user selects the tray icon, using either the mouse or keyboard.
public synchronized  voidaddMouseListener(MouseListener listener)
     Adds the specified mouse listener to receive mouse events from this TrayIcon.
public synchronized  voidaddMouseMotionListener(MouseMotionListener listener)
     Adds the specified mouse listener to receive mouse-motion events from this TrayIcon.
 voidaddNotify()
    
 voiddispatchEvent(AWTEvent e)
    
public  voiddisplayMessage(String caption, String text, MessageType messageType)
     Displays a popup message near the tray icon.
public  StringgetActionCommand()
     Returns the command name of the action event fired by this tray icon.
public synchronized  ActionListener[]getActionListeners()
     Returns an array of all the action listeners registered on this TrayIcon.
 intgetID()
    
public  ImagegetImage()
     Returns the current image used for this TrayIcon.
 T[]getListeners(Class<T> listenerType)
    
public synchronized  MouseListener[]getMouseListeners()
     Returns an array of all the mouse listeners registered on this TrayIcon.
public synchronized  MouseMotionListener[]getMouseMotionListeners()
     Returns an array of all the mouse-motion listeners registered on this TrayIcon.
public  PopupMenugetPopupMenu()
     Returns the popup menu associated with this TrayIcon.
public  DimensiongetSize()
     Returns the size, in pixels, of the space that the tray icon occupies in the system tray.
public  StringgetToolTip()
     Returns the tooltip string associated with this TrayIcon.
public  booleanisImageAutoSize()
     Returns the value of the auto-size property.
 voidprocessActionEvent(ActionEvent e)
    
 voidprocessEvent(AWTEvent e)
    
 voidprocessMouseEvent(MouseEvent e)
    
 voidprocessMouseMotionEvent(MouseEvent e)
    
public synchronized  voidremoveActionListener(ActionListener listener)
     Removes the specified action listener.
public synchronized  voidremoveMouseListener(MouseListener listener)
     Removes the specified mouse listener.
public synchronized  voidremoveMouseMotionListener(MouseMotionListener listener)
     Removes the specified mouse-motion listener.
 voidremoveNotify()
    
public  voidsetActionCommand(String command)
     Sets the command name for the action event fired by this tray icon.
 voidsetID(int id)
    
public  voidsetImage(Image image)
     Sets the image for this TrayIcon.
public  voidsetImageAutoSize(boolean autosize)
     Sets the auto-size property.
public  voidsetPopupMenu(PopupMenu popup)
     Sets the popup menu for this TrayIcon.
public  voidsetToolTip(String tooltip)
     Sets the tooltip string for this TrayIcon.

Field Detail
actionListener
transient ActionListener actionListener(Code)



mouseListener
transient MouseListener mouseListener(Code)



mouseMotionListener
transient MouseMotionListener mouseMotionListener(Code)




Constructor Detail
TrayIcon
public TrayIcon(Image image)(Code)
Creates a TrayIcon with the specified image.
Parameters:
  image - the Image to be used
throws:
  IllegalArgumentException - if image isnull
throws:
  UnsupportedOperationException - if the system tray isn'tsupported by the current platform
throws:
  HeadlessException - if GraphicsEnvironment.isHeadless() returns true
throws:
  SecurityException - if accessSystemTray permissionis not granted
See Also:   SystemTray.add(TrayIcon)
See Also:   TrayIcon.TrayIcon(ImageStringPopupMenu)
See Also:   TrayIcon.TrayIcon(ImageString)
See Also:   SecurityManager.checkPermission
See Also:   AWTPermission



TrayIcon
public TrayIcon(Image image, String tooltip)(Code)
Creates a TrayIcon with the specified image and tooltip text.
Parameters:
  image - the Image to be used
Parameters:
  tooltip - the string to be used as tooltip text; if thevalue is null no tooltip is shown
throws:
  IllegalArgumentException - if image isnull
throws:
  UnsupportedOperationException - if the system tray isn'tsupported by the current platform
throws:
  HeadlessException - if GraphicsEnvironment.isHeadless() returns true
throws:
  SecurityException - if accessSystemTray permissionis not granted
See Also:   SystemTray.add(TrayIcon)
See Also:   TrayIcon.TrayIcon(Image)
See Also:   TrayIcon.TrayIcon(ImageStringPopupMenu)
See Also:   SecurityManager.checkPermission
See Also:   AWTPermission



TrayIcon
public TrayIcon(Image image, String tooltip, PopupMenu popup)(Code)
Creates a TrayIcon with the specified image, tooltip and popup menu.
Parameters:
  image - the Image to be used
Parameters:
  tooltip - the string to be used as tooltip text; if thevalue is null no tooltip is shown
Parameters:
  popup - the menu to be used for the tray icon's popupmenu; if the value is null no popup menu is shown
throws:
  IllegalArgumentException - if image is null
throws:
  UnsupportedOperationException - if the system tray isn'tsupported by the current platform
throws:
  HeadlessException - if GraphicsEnvironment.isHeadless() returns true
throws:
  SecurityException - if accessSystemTray permissionis not granted
See Also:   SystemTray.add(TrayIcon)
See Also:   TrayIcon.TrayIcon(ImageString)
See Also:   TrayIcon.TrayIcon(Image)
See Also:   PopupMenu
See Also:   MouseListener
See Also:   TrayIcon.addMouseListener(MouseListener)
See Also:   SecurityManager.checkPermission
See Also:   AWTPermission




Method Detail
addActionListener
public synchronized void addActionListener(ActionListener listener)(Code)
Adds the specified action listener to receive ActionEvents from this TrayIcon. Action events usually occur when a user selects the tray icon, using either the mouse or keyboard. The conditions in which action events are generated are platform-dependent.

Calling this method with a null value has no effect.

Refer to AWT Threading Issues for details on AWT's threading model.
Parameters:
  listener - the action listener
See Also:   TrayIcon.removeActionListener
See Also:   TrayIcon.getActionListeners
See Also:   java.awt.event.ActionListener
See Also:   TrayIcon.setActionCommand(String)




addMouseListener
public synchronized void addMouseListener(MouseListener listener)(Code)
Adds the specified mouse listener to receive mouse events from this TrayIcon. Calling this method with a null value has no effect.

Note: The MouseEvent 's coordinates (received from the TrayIcon ) are relative to the screen, not the TrayIcon .

Note: The MOUSE_ENTERED and MOUSE_EXITED mouse events are not supported.

Refer to AWT Threading Issues for details on AWT's threading model.
Parameters:
  listener - the mouse listener
See Also:   java.awt.event.MouseEvent
See Also:   java.awt.event.MouseListener
See Also:   TrayIcon.removeMouseListener(MouseListener)
See Also:   TrayIcon.getMouseListeners




addMouseMotionListener
public synchronized void addMouseMotionListener(MouseMotionListener listener)(Code)
Adds the specified mouse listener to receive mouse-motion events from this TrayIcon. Calling this method with a null value has no effect.

Note: The MouseEvent 's coordinates (received from the TrayIcon ) are relative to the screen, not the TrayIcon .

Note: The MOUSE_DRAGGED mouse event is not supported.

Refer to AWT Threading Issues for details on AWT's threading model.
Parameters:
  listener - the mouse listener
See Also:   java.awt.event.MouseEvent
See Also:   java.awt.event.MouseMotionListener
See Also:   TrayIcon.removeMouseMotionListener(MouseMotionListener)
See Also:   TrayIcon.getMouseMotionListeners




addNotify
void addNotify() throws AWTException(Code)



dispatchEvent
void dispatchEvent(AWTEvent e)(Code)



displayMessage
public void displayMessage(String caption, String text, MessageType messageType)(Code)
Displays a popup message near the tray icon. The message will disappear after a time or if the user clicks on it. Clicking on the message may trigger an ActionEvent .

Either the caption or the text may be null, but an NullPointerException is thrown if both are null. When displayed, the caption or text strings may be truncated on some platforms; the number of characters that may be displayed is platform-dependent.

Note: Some platforms may not support showing a message.
Parameters:
  caption - the caption displayed above the text, usually inbold; may be null
Parameters:
  text - the text displayed for the particular message; may benull
Parameters:
  messageType - an enum indicating the message type
throws:
  NullPointerException - if both captionand text are null




getActionCommand
public String getActionCommand()(Code)
Returns the command name of the action event fired by this tray icon. the action command name, or null if none exists
See Also:   TrayIcon.addActionListener(ActionListener)
See Also:   TrayIcon.setActionCommand(String)



getActionListeners
public synchronized ActionListener[] getActionListeners()(Code)
Returns an array of all the action listeners registered on this TrayIcon. all of the ActionListeners registered onthis TrayIcon or an empty array if no actionlisteners are currently registered
See Also:   TrayIcon.addActionListener(ActionListener)
See Also:   TrayIcon.removeActionListener(ActionListener)
See Also:   java.awt.event.ActionListener



getID
int getID()(Code)



getImage
public Image getImage()(Code)
Returns the current image used for this TrayIcon. the image
See Also:   TrayIcon.setImage(Image)
See Also:   Image



getListeners
T[] getListeners(Class<T> listenerType)(Code)



getMouseListeners
public synchronized MouseListener[] getMouseListeners()(Code)
Returns an array of all the mouse listeners registered on this TrayIcon. all of the MouseListeners registered onthis TrayIcon or an empty array if no mouselisteners are currently registered
See Also:   TrayIcon.addMouseListener(MouseListener)
See Also:   TrayIcon.removeMouseListener(MouseListener)
See Also:   java.awt.event.MouseListener



getMouseMotionListeners
public synchronized MouseMotionListener[] getMouseMotionListeners()(Code)
Returns an array of all the mouse-motion listeners registered on this TrayIcon. all of the MouseInputListeners registered onthis TrayIcon or an empty array if no mouselisteners are currently registered
See Also:   TrayIcon.addMouseMotionListener(MouseMotionListener)
See Also:   TrayIcon.removeMouseMotionListener(MouseMotionListener)
See Also:   java.awt.event.MouseMotionListener



getPopupMenu
public PopupMenu getPopupMenu()(Code)
Returns the popup menu associated with this TrayIcon. the popup menu or null if none exists
See Also:   TrayIcon.setPopupMenu(PopupMenu)



getSize
public Dimension getSize()(Code)
Returns the size, in pixels, of the space that the tray icon occupies in the system tray. For the tray icon that is not yet added to the system tray, the returned size is equal to the result of the SystemTray.getTrayIconSize . the size of the tray icon, in pixels
See Also:   TrayIcon.setImageAutoSize(boolean)
See Also:   java.awt.Image
See Also:   TrayIcon.getSize



getToolTip
public String getToolTip()(Code)
Returns the tooltip string associated with this TrayIcon. the tooltip string or null if none exists
See Also:   TrayIcon.setToolTip(String)



isImageAutoSize
public boolean isImageAutoSize()(Code)
Returns the value of the auto-size property. true if the image will be auto-sized,false otherwise
See Also:   TrayIcon.setImageAutoSize(boolean)



processActionEvent
void processActionEvent(ActionEvent e)(Code)



processEvent
void processEvent(AWTEvent e)(Code)



processMouseEvent
void processMouseEvent(MouseEvent e)(Code)



processMouseMotionEvent
void processMouseMotionEvent(MouseEvent e)(Code)



removeActionListener
public synchronized void removeActionListener(ActionListener listener)(Code)
Removes the specified action listener. Calling this method with null or an invalid value has no effect.

Refer to AWT Threading Issues for details on AWT's threading model.
Parameters:
  listener - the action listener
See Also:   java.awt.event.ActionEvent
See Also:   java.awt.event.ActionListener
See Also:   TrayIcon.addActionListener(ActionListener)
See Also:   TrayIcon.getActionListeners
See Also:   TrayIcon.setActionCommand(String)




removeMouseListener
public synchronized void removeMouseListener(MouseListener listener)(Code)
Removes the specified mouse listener. Calling this method with null or an invalid value has no effect.

Refer to AWT Threading Issues for details on AWT's threading model.
Parameters:
  listener - the mouse listener
See Also:   java.awt.event.MouseEvent
See Also:   java.awt.event.MouseListener
See Also:   TrayIcon.addMouseListener(MouseListener)
See Also:   TrayIcon.getMouseListeners




removeMouseMotionListener
public synchronized void removeMouseMotionListener(MouseMotionListener listener)(Code)
Removes the specified mouse-motion listener. Calling this method with null or an invalid value has no effect.

Refer to AWT Threading Issues for details on AWT's threading model.
Parameters:
  listener - the mouse listener
See Also:   java.awt.event.MouseEvent
See Also:   java.awt.event.MouseMotionListener
See Also:   TrayIcon.addMouseMotionListener(MouseMotionListener)
See Also:   TrayIcon.getMouseMotionListeners




removeNotify
void removeNotify()(Code)



setActionCommand
public void setActionCommand(String command)(Code)
Sets the command name for the action event fired by this tray icon. By default, this action command is set to null.
Parameters:
  command - a string used to set the tray icon'saction command.
See Also:   java.awt.event.ActionEvent
See Also:   TrayIcon.addActionListener(ActionListener)
See Also:   TrayIcon.getActionCommand



setID
void setID(int id)(Code)



setImage
public void setImage(Image image)(Code)
Sets the image for this TrayIcon. The previous tray icon image is discarded without calling the java.awt.Image.flush method — you will need to call it manually.

If the image represents an animated image, it will be animated automatically.

See the TrayIcon.setImageAutoSize(boolean) property for details on the size of the displayed image.

Calling this method with the same image that is currently being used has no effect.
throws:
  NullPointerException - if image is null
Parameters:
  image - the non-null Image to be used
See Also:   TrayIcon.getImage
See Also:   Image
See Also:   SystemTray.add(TrayIcon)
See Also:   TrayIcon.TrayIcon(ImageString)




setImageAutoSize
public void setImageAutoSize(boolean autosize)(Code)
Sets the auto-size property. Auto-size determines whether the tray image is automatically sized to fit the space allocated for the image on the tray. By default, the auto-size property is set to false.

If auto-size is false, and the image size doesn't match the tray icon space, the image is painted as-is inside that space — if larger than the allocated space, it will be cropped.

If auto-size is true, the image is stretched or shrunk to fit the tray icon space.
Parameters:
  autosize - true to auto-size the image,false otherwise
See Also:   TrayIcon.isImageAutoSize




setPopupMenu
public void setPopupMenu(PopupMenu popup)(Code)
Sets the popup menu for this TrayIcon. If popup is null, no popup menu will be associated with this TrayIcon.

Note that this popup must not be added to any parent before or after it is set on the tray icon. If you add it to some parent, the popup may be removed from that parent.

The popup can be set on one TrayIcon only. Setting the same popup on multiple TrayIcon s will cause an IllegalArgumentException .

Note: Some platforms may not support showing the user-specified popup menu component when the user right-clicks the tray icon. In this situation, either no menu will be displayed or, on some systems, a native version of the menu may be displayed.
throws:
  IllegalArgumentException - if the popup is alreadyset for another TrayIcon
Parameters:
  popup - a PopupMenu or null toremove any popup menu
See Also:   TrayIcon.getPopupMenu




setToolTip
public void setToolTip(String tooltip)(Code)
Sets the tooltip string for this TrayIcon. The tooltip is displayed automatically when the mouse hovers over the icon. Setting the tooltip to null removes any tooltip text. When displayed, the tooltip string may be truncated on some platforms; the number of characters that may be displayed is platform-dependent.
Parameters:
  tooltip - the string for the tooltip; if the value isnull no tooltip is shown
See Also:   TrayIcon.getToolTip



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.