SysTray for Java
v2.4.1  

snoozesoft.systray4j
Class SysTrayMenuIcon

java.lang.Object
  extended bysnoozesoft.systray4j.SysTrayMenuIcon

public class SysTrayMenuIcon
extends java.lang.Object

This class represents a platform specific icon file. The supported formats are *.ico on win32, and *.xpm on KDE. Usually on KDE the dimension of the icon is 24 x 24, and 16 x 16 or 32 x 32 on Windows.

Interested listeners are called whenever this icon is clicked.


Constructor Summary
SysTrayMenuIcon(java.lang.String iconFileName)
          Creates a new SysTrayMenuIcon object.
SysTrayMenuIcon(java.lang.String iconFileName, java.lang.String actionCommand)
          Creates a new SysTrayMenuIcon object.
SysTrayMenuIcon(java.net.URL icon)
          Creates a new SysTrayMenuIcon object from the file pointed to by the URL.
SysTrayMenuIcon(java.net.URL icon, java.lang.String actionCommand)
          Creates a new SysTrayMenuIcon object from the file pointed to by the URL.
 
Method Summary
 void addSysTrayMenuListener(SysTrayMenuListener listener)
          Adds the specified listener to receive events from this icon.
 java.lang.String getActionCommand()
          Getter for the action command.
static java.lang.String getExtension()
          This method returns the correct icon file extension for the actual platform.
 java.lang.String getName()
          Getter for the file name associated with this object.
 void removeSysTrayMenuListener(SysTrayMenuListener listener)
          Removes the specified listener so that it no longer receives events from this menu item.
 void setActionCommand(java.lang.String actionCommand)
          Setter for the action command.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SysTrayMenuIcon

public SysTrayMenuIcon(java.lang.String iconFileName)

Creates a new SysTrayMenuIcon object.

Since the file extension (ico/xpm) depends on the actual platform, it is allowed, but not necessary to specify it.

Example:
  realFileName: duke.ico
  passedFileName: duke or duke.ico

Parameters:
iconFileName - The associated file name.

SysTrayMenuIcon

public SysTrayMenuIcon(java.lang.String iconFileName,
                       java.lang.String actionCommand)
Creates a new SysTrayMenuIcon object.

Since the file extension (ico/xpm) depends on the actual platform, it is allowed, but not necessary to specify it.

Example:
  realFileName: duke.ico
  passedFileName: duke or duke.ico

Parameters:
iconFileName - The associated file name.
actionCommand - The action command passed to the listeners.

SysTrayMenuIcon

public SysTrayMenuIcon(java.net.URL icon)

Creates a new SysTrayMenuIcon object from the file pointed to by the URL.

This constructor makes it possible to store the icon files together with the application classes in a JAR file.

One possibility to get the URL of an icon is through the getResource() method:


provided that the icon is in the same path where the class is stored.

Parameters:
icon - The URL of the icon.

SysTrayMenuIcon

public SysTrayMenuIcon(java.net.URL icon,
                       java.lang.String actionCommand)

Creates a new SysTrayMenuIcon object from the file pointed to by the URL.

This constructor makes it possible to store the icon files together with the application classes in a JAR file.

One possibility to get the URL of an icon is through the getResource() method:


provided that the icon is in the same path where the class is stored.

Parameters:
icon - The URL of the icon.
actionCommand - The action command passed to the listeners.
Method Detail

addSysTrayMenuListener

public void addSysTrayMenuListener(SysTrayMenuListener listener)
Adds the specified listener to receive events from this icon.

Parameters:
listener - The systray menu listener.

getActionCommand

public java.lang.String getActionCommand()
Getter for the action command.

Returns:
The action command passed to the listeners.

getExtension

public static java.lang.String getExtension()
This method returns the correct icon file extension for the actual platform.

Returns:
".ico" ro ".xpm" depending on the platform.

getName

public java.lang.String getName()
Getter for the file name associated with this object.

Returns:
The associated file name.

removeSysTrayMenuListener

public void removeSysTrayMenuListener(SysTrayMenuListener listener)
Removes the specified listener so that it no longer receives events from this menu item.

Parameters:
listener - The systray menu listener.

setActionCommand

public void setActionCommand(java.lang.String actionCommand)
Setter for the action command.

Parameters:
actionCommand - The action command passed to the listeners.

SysTray for Java
v2.4.1