net.xoetrope.swing.deploy
Class XSystemTrayManager

java.lang.Object
  extended by net.xoetrope.swing.deploy.XSystemTrayManager
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, javax.jnlp.SingleInstanceListener

public class XSystemTrayManager
extends java.lang.Object
implements java.awt.event.ActionListener, javax.jnlp.SingleInstanceListener

A manager class for tray actions. When a system tray icon is added the application can choose to stay resident in memory after the main window has been closed by setting the ExitOnClose startup property to false. The advantage of doing this is that the data model does not need to be reinitialized if the main window is just being redisplayed.

The tray icon provides two menu items, one to open the window and the second to close the window and exit the JVM.

This version of the class uses the SwingLabs version of the tray support and is therefore limited to Swing. If JDK 6 or later is being used then the JVM's tray support could be used for non Swing applications

If the application is launched via JavaWebStart then the XSystemTrayManager is installed as a singleton and each subsequent invocation via JWS will cause a new activation. If the application has set an "ActivationObject" via the project.setObject( "ActivationObject", XActivation ) then the XActivation.activate method is invoked and the appliction can check the startup properties and perform the appropriate action.

Copyright (c) Xoetrope Ltd., 2001-2007, see license.txt for details


Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Relaunch the application
static XSystemTrayManager getInstance(XProject project)
           
 void newActivation(java.lang.String[] args)
          Specified by the JNLP SingleInstanceListener interface.
 void setStripSplashArgument(boolean state)
          Set a flag to strip the extra argument added when a splash screen is used at startup.
 void showActivationEvent()
          Invoke any registered activation event
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static XSystemTrayManager getInstance(XProject project)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Relaunch the application

Specified by:
actionPerformed in interface java.awt.event.ActionListener

newActivation

public void newActivation(java.lang.String[] args)
Specified by the JNLP SingleInstanceListener interface. Called when a new application instance is being started

Specified by:
newActivation in interface javax.jnlp.SingleInstanceListener
Parameters:
args - The command line parameters used for this invocation

setStripSplashArgument

public void setStripSplashArgument(boolean state)
Set a flag to strip the extra argument added when a splash screen is used at startup. The XSplashWindow class requires an extra argument of the 'main' class proper, but strips this before passing the arguments to that class. Setting this flag to true replicates that behavior for the startup via the system tray when a second JNLP invocation occurs. This is necessary as the new JNLP invocation provides a fresh set of startup arguments

Parameters:
state - true to strip the first argument

showActivationEvent

public void showActivationEvent()
Invoke any registered activation event