Hello, FPC list!

Is there anyone who knows how to write a JVM applet with FPC?

I have this minimal Java applet:

import java.applet.*;

import java.awt.*;

public class HelloWorldApplet extends Applet

{

   public void paint (Graphics g)

   {

      g.drawString ("Hello World", 25, 50);

   }

}


AFAIK this translates to:

{$mode objfpc}

// I try to make an Applet. How?

program HelloWorldAppletProgram;

uses

    jdk15;

type

    HelloWorldApplet = class(JAApplet)

    public

        procedure paint(g: JAGraphics);override;

    end;

    procedure HelloWorldApplet.paint(g: JAGraphics);

    begin

        g.drawString('Hello World (FPC)',25,50);

    end;

begin

end.


Compiles, produces HelloWorldAppletProgram.class and HelloWorldApplet.class.

FPC compilation line:

/usr/local/bin/ppcjvm -O2 -g HelloWorldAppletProgram.pas -XP -FD/usr/local/bin/

Java compilation line:

/usr/bin/javac HelloWorldApplet.java

Uses this HTML file:

<title>HelloWorldApplet</title><hr>
<applet archive="AppletClasses.jar" code="HelloWorldApplet.class"
width=200 height=200></applet>


Should IMHO run with

appletviewer HelloWorldApplet.html

It compiles with both Java and FPC, but the FPC version doesn't run.

Any ideas? Any obvious mistakes of mine?


/Ingemar

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to