#include <Pandora JVM.h>

/********************************************* FileMenu *************************************************/
struct FileMenu	:	public PMenu
{
	FileMenu();
	
	virtual	void	menuPrepare() {}
	virtual	void	handleMenuSelection(unsigned short item);
};

/********************************************* MyApplication *************************************************/
struct MyApplication	:	public PApplication
{
	FileMenu				fileMenu;
};

/********************************************* The application *************************************************/
MyApplication* theApp = nil;

/********************************************* The program *************************************************/
void main(void)
{
	try
	{
		unsigned char	myByteCode[] = {0x00,0x00,0xCA,0xE6,0xE7,0xFF};	// add,add,add,add,sub,sub,quit
		PJavaRegs	regs = {myByteCode,nil};
		
		PInterpretBytecode(&regs);
		
		theApp = new MyApplication;
		theApp->run();
	}
	catch(PErr err)
	{
		dout << "Error " << err << " was thrown and caught in main()!\n";
	}
	catch(...)
	{
		dout << "Some really weird error was caught in main() - it wasn't even a PErr!\n";
	}
	
	delete theApp;
}

/********************************************* FileMenu methods *************************************************/
FileMenu::FileMenu():
	PMenu("File")
{
	addMenuItem("Quit",'Q');
}

void FileMenu::handleMenuSelection(unsigned short item)
{
	if(item == 1)
		theApp->quit();
}
