Description
Enables SystemTray and TrayIcon support on your Griffon application.
The TrayIcon class is actually JPopupTrayIcon by Michael Biem (from the Fishfarm project), which in turn is based on Alex Potochkin's JXTrayIcon. In short words this class allows you to display a JPopupMenu in the systemTray as opposed to a regular, plain PopupMenu (AWT stuff, yuck!)
Installation
The current version of griffon-tray-builder-plugin is 0.2
To install just issue the following command
griffon install-plugin tray-builder
| Warning This plugin requires JDK6 to be installed, it will also constrain the running environment to JRE6 or above. |
Usage
There is no standalone builder as opposed to the other builder plugins, as this one only adds 2 node factories and relies on Griffon's CompositeBuilder to be mixed&matched with other SwingBuilder based builders, those factories are
| Node | Property | Type | Default | Required | Bindable | Notes |
|---|---|---|---|---|---|---|
| systemTray [SystemTray] |
trayIcons | TrayIcon[] | |
|
readonly | |
| trayIconSize | Dimension | |
|
readonly | ||
| trayIcon [JPopupTrayIcon] |
url | URL | |
|
||
| file | File | |
|
can also be a String | ||
| inputStream | InputStream | |
|
|||
| resource | String | |
|
|||
| class | Class | |
|
only required if resource is specified. | ||
| specify one of url, file, inputStream, resource or use a String as node value. | ||||||
| accepts JPopupMenu instances as children only. |
The following is an example of its usage provided by SwingPad as sample script:
import groovy.ui.Console import static java.awt.TrayIcon.MessageType.* actions { action(id: 'cutAction', name: 'Cut', closure: { trayIcon.displayMessage("Cut","Cut some content",NONE)}, mnemonic: 'T', accelerator: shortcut('X'), smallIcon: imageIcon(resource:"icons/cut.png", class: Console), shortDescription: 'Cut' ) action(id: 'copyAction', name: 'Copy', closure: { trayIcon.displayMessage("Copy","Copy some content",INFO)}, mnemonic: 'C', accelerator: shortcut('C'), smallIcon: imageIcon(resource:"icons/page_copy.png", class: Console), shortDescription: 'Copy' ) action(id: 'pasteAction', name: 'Paste', closure: { trayIcon.displayMessage("Paste","Paste some content",WARNING)}, mnemonic: 'P', accelerator: shortcut('V'), smallIcon: imageIcon(resource:"icons/page_paste.png", class: Console), shortDescription: 'Paste' ) action( id: 'exitAction', name: 'Quit', closure: { trayIcon.displayMessage("Quit","No can do!",ERROR)}, mnemonic: 'Q', accelerator: shortcut('Q'), shortDescription: 'Quit' ) } systemTray { trayIcon(id: "trayIcon", resource: "/groovy/ui/ConsoleIcon.png", class: groovy.ui.Console, toolTip: "Double click on me and I'll go away!", actionPerformed: {systemTray.remove(trayIcon)}) { popupMenu { menuItem(cutAction) menuItem(copyAction) menuItem(pasteAction) separator() menuItem(exitAction) } } }
A variable systemTray is available for your convenience, it points to the SystemTray instance. |


