![]() ![]() The complete code for this demo is available in the MenuItem exitItem = new MenuItem("Exit") MenuItem noneItem = new MenuItem("None") MenuItem infoItem = new MenuItem("Info") MenuItem warningItem = new MenuItem("Warning") MenuItem errorItem = new MenuItem("Error") MenuItem aboutItem = new MenuItem("About") ĬheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size") ĬheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip") New TrayIcon(createImage("images/bulb.gif", "tray icon")) įinal SystemTray tray = SystemTray.getSystemTray() The workaround proposal for this issue is described in the Bug Database, see Bug ID 6285881. Unfortunately, the current implementation of the TrayIcon class provides limited support of the Swing pop-up menu (the JPopupMenu class) and does not enable an application to use all of the capabilities of the javax.swing package. The following demo, developed using the AWT package, demonstrates the features of SystemTray and TrayIcon classes. ![]() The icon image is automatically resized to fit the space allocated for the image on the tray. When the mouse pointer hovers over the tray icon, the tooltip is displayed. When a double-click is performed, the TrayIcon object generates an ActionEvent to launch an application. For example, by default, when a right-click is performed on the tray icon, it displays the specified pop-up menu. The TrayIcon class processes some of the events itself. A TrayIcon object generates various mouse events and supports the addition of corresponding listeners to receive notification of these events. It also includes a text tooltip, a popup menu, balloon messages, and a set of listeners associated with it. TrayIcon class functionality goes beyond the icon that is displayed in the tray. For example, an AWTException will be thrown by X-Window desktops if the system tray does not exist on the desktop. Note: The add() method can throw an AWTException if the operating system or the Java runtime determines that the icon cannot be added to the system tray. They can be removed when they are no longer needed with the The system tray contains one or more tray icons which are added to the tray using theĪdd() method. Only a single instance created within this class can exist, and this instance can be obtained using the If the application attempts to call the getSystemTray() method in such a case, the method will throw a .Īn application cannot create an instance of the SystemTray class. If the system tray is not supported on this platform, the isSupported() method returns false. IsSupported() to check that the system tray is supported. Before calling this method, use the static method The system tray can be accessed by calling the static SystemTray.getSystemTray() method. class introduced in Java™ SE version 6 represents the system tray for a desktop. However, on each system the tray area is shared by all applications running on the desktop. On K Desktop Environment (KDE) this area is referred to as the System Tray. On Microsoft Windows, the system tray is referred to as the Taskbar Status Area, while on the GNU Network Object Model Environment (GNOME) Desktop it is referred to as the Notification Area. This area may be referred to differently on various operating systems. The system tray is a specialized area of the desktop where users can access currently running programs.
0 Comments
Leave a Reply. |