org.formaria.swing.deploy
Class SystemTrayManager

java.lang.Object
  extended by org.formaria.swing.deploy.SystemTrayManager
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class SystemTrayManager
extends java.lang.Object
implements java.awt.event.ActionListener

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 SystemTrayManager 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", Activation ) then the Activation.activate method is invoked and the appliction can check the startup properties and perform the appropriate action.

Copyright (c) Formaria Ltd., 2008, see license.txt for details


Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Relaunch the application
static SystemTrayManager getInstance(Project 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 SystemTrayManager getInstance(Project 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

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 SplashWindow 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