package viewer;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;

public class HelpFrame
{
	private static JFrame frame = null;

	public HelpFrame()
	{
		if ( frame != null )
			frame.toFront();
		else
		{
			try
			{
				frame = new JFrame( "Help" );
				final JEditorPane editorPane = new JEditorPane( new HelpFrame().getClass().getResource( "Help.html" ) );
				editorPane.setEditable( false );
				editorPane.setBorder( BorderFactory.createEmptyBorder( 10, 0, 10, 10 ) );

				final JScrollPane editorScrollPane = new JScrollPane( editorPane );
				editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
				editorScrollPane.setPreferredSize( new Dimension( 800, 800 ) );

				final Container content = frame.getContentPane();
				content.add( editorScrollPane, BorderLayout.CENTER );

				frame.addWindowListener( new WindowAdapter()
				{
					@Override
					public void windowClosing( final WindowEvent e )
					{
						frame = null;
					}
				} );

				final ActionMap am = frame.getRootPane().getActionMap();
				final InputMap im = frame.getRootPane().getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
				final Object hideKey = new Object();
				final Action hideAction = new AbstractAction()
				{
					private static final long serialVersionUID = 6288745091648466880L;

					@Override
					public void actionPerformed( final ActionEvent e )
					{
						frame.dispose();
						frame = null;
					}
				};
				im.put( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), hideKey );
				am.put( hideKey, hideAction );

				frame.pack();
				frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
				frame.setVisible( true );
			}
			catch ( final IOException e )
			{
				e.printStackTrace();
			}
		}
	}
}

@@ -260,16 +260,37 @@
 ception;
+%0Aimport java.net.URL;
 %0A%0Aimport
@@ -659,25 +659,344 @@
 ;%0A%0A%09
-public HelpFrame(
+/**%0A%09 * Instantiates and displays a JFrame that lists the help file for the SPIM viewer UI.   %0A%09 */%0A%09public HelpFrame()%0A%09%7B%0A%09%09this( HelpFrame.class.getResource( %22Help.html%22 ) );%0A%09%7D%0A%09%0A%09/**%0A%09 * Instantiates and displays a JFrame that lists the content of a html file%0A%09 * specified by its %7B@link URL%7D.   %0A%09 */%0A%09public HelpFrame(URL helpFile
 )%0A%09%7B
@@ -1152,61 +1152,16 @@
 ne( 
-new HelpFrame().getClass().getResource( %22Help.html%22 )
+helpFile
  );%0A

Make the HelpFrame re-usable for other help texts