Converting Applets to Applications

You can compare the code of this application with that of Dharmesh Tailor's original applet and see that we have made additions without changing any of his code. We
have added javax.swing (for the JFrame to contain an object of the existing applet class) to the uses clause, declared the
Main method in the interface section, then coded the Main method at the end of the program. We must call the init and start methods of the applet (which are normally called by the browser). The browsers installed on the Raspberry Pi are not yet Java-enabled, but we can run the application on the Pi with the java
program in the open JDK:

Java application (from applet) running on the Pi

We needed to set the OutputType to Executable in the .oxygene project file to obtain this jar file.

Oxygene code

namespacemouse_application;{
Original applet to demonstrate mouse event handlers
Copyright (c) 2012 Dharmesh Tailor
Converted from applet to application by PPS
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License, as described at
http://www.apache.org/licenses/ and http://www.pp4s.co.uk/licenses/
}interfaceusesjava.applet.*,
java.awt,
java.awt.event,
javax.swing;typeMouseApplet=publicclass(Applet, MouseListener, MouseMotionListener)privatevarmsg:String:='';//Coordinates of mousevarmouseX:Integer:=0;varmouseY:Integer:=0;publicmethodinit;override;methodmouseClicked(me:MouseEvent);methodmouseEntered(me:MouseEvent);methodmouseExited(me:MouseEvent);methodmousePressed(me:MouseEvent);methodmouseReleased(me:MouseEvent);methodmouseDragged(me:MouseEvent);methodmouseMoved(me:MouseEvent);methodpaint(g:Graphics);override;end;ConsoleApp=classpublicclassmethodMain(args:arrayofString);end;implementationmethodMouseApplet.init;beginBackground:=Color.gray;addMouseListener(self);addMouseMotionListener(self);end;methodMouseApplet.mouseClicked(me:MouseEvent);beginmouseX:=0;mouseY:=10;msg:='Mouse clicked.';repaint;end;methodMouseApplet.mouseEntered(me:MouseEvent);beginmouseX:=0;mouseY:=10;msg:='Mouse entered.';repaint;end;methodMouseApplet.mouseExited(me:MouseEvent);beginmouseX:=0;mouseY:=10;msg:='Mouse exited.';repaint;end;methodMouseApplet.mousePressed(me:MouseEvent);beginmouseX:=me.X;mouseY:=me.Y;msg:='Down';repaint;end;methodMouseApplet.mouseReleased(me:MouseEvent);beginmouseX:=me.X;mouseY:=me.Y;msg:='Up';repaint;end;methodMouseApplet.mouseDragged(me:MouseEvent);beginmouseX:=0;mouseY:=10;msg:='Dragging mouse at '+me.X+', '+me.Y;repaint;end;methodMouseApplet.mouseMoved(me:MouseEvent);beginend;methodMouseApplet.paint(g:Graphics);beging.drawString(msg, mouseX, mouseY);end;classmethodConsoleApp.Main(args:arrayofString);beginvarAppletFrame:JFrame:=newJFrame('Mouse Application');varMyMouseApplet:MouseApplet:=newMouseApplet;AppletFrame.add("Center", MyMouseApplet);AppletFrame.setSize(300, 200);AppletFrame.setVisible(True);AppletFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);MyMouseApplet.init;MyMouseApplet.start;end;end.