package my.simple;

import jas.plugin.*;
import jas.util.JASIcon;
import javax.swing.*;
import java.util.Date;

public class Extension extends ExtensionPlugin
{
	public Extension()
	{
		// Dont to anything here, wait until the framework calls init()
	}
	/**
	 * Create our menu and install it.
	 */
	public void init()
	{
		JMenu menu = new JMenu("Simple");
		menu.add(new MyAction());
		this.addMenu(menu);
	}
	private class MyAction extends AbstractAction
	{
		MyAction()
		{
			super("Time and Memory Usage",JASIcon.create(Extension.this,"Clock.gif"));
		}
		public void actionPerformed(java.awt.event.ActionEvent e)
		{
			Runtime runtime = Runtime.getRuntime();
			long mem = (runtime.totalMemory() - runtime.freeMemory());
			sendMessage("At "+new Date()+" the memory usage is "+mem+" bytes");
		}
	}
}
