Solved

How do I debug a java applet?

Posted on 1998-03-19
5
186 Views
Last Modified: 2013-11-23
How do I debug a java applet? But please some better answers then System.out.println.

Regards Ian
0
Comment
Question by:e4monsch
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:gadio
ID: 1233680
There are tools that enable you to debug an applet. However assuming that you don't use such a tool, you can take any applet that you write and turn in into a stand alone application. Doing that you can use the jdb debugger (in the jdk package) and all the common java development tolls debuggers. In order to do that you should add a static main function to the applet, and in it to open a frame, instantiate the applet, lay it out in the frame and call the init and start methods of the applet. Here is a small sample code that does that.
------
import java.applet.*;
import java.awt.*;

public class simpleApplet1 extends Applet {
  TextField text;

  public simpleApplet1() {
        text = new TextField(20);
        add( text );
  }

  /*
   .... applet stuff comes here ...
  */

  public static void main( String args[] ) {
    simpleApplet1 ap = new simpleApplet1();
    frameApplet fr = new frameApplet(ap);
    fr.resize(200,100);
    fr.show();
    ap.init();
    ap.start();
  }
}


class frameApplet extends Frame {
  public frameApplet( Applet ap ) {
    add(ap);
  }
}
---------
This applet can be run as an applet or as a stand alone.
Hope that helps.
G.
0
 
LVL 2

Author Comment

by:e4monsch
ID: 1233681
I use Kawa as a IDE. Do you know how I can debug an applet with Kawa? (Appart of your obove suggestion.

Regards Ian

0
 

Expert Comment

by:Ant031898
ID: 1233682
Get JBuilder - it has a debugger build in
0
 
LVL 2

Author Comment

by:e4monsch
ID: 1233683
Gadio will get the points. I'll reopen the question to give Gadio a change to mark it as answer so I can give him the points.

Regards Ian

0
 
LVL 6

Accepted Solution

by:
gadio earned 20 total points
ID: 1233684
Ok, I'll paste in my answer again so that it will be stored:

  There are tools that enable you to debug an applet. However assuming that you don't use such a tool, you can take any applet that you write and turn in into a stand alone application. Doing that you can use the jdb debugger (in the jdk package) and all the common java development tolls debuggers. In order to do that you should add a static main function to the applet, and in it to open a frame, instantiate the applet, lay it out in the frame and call the init and start methods of the applet. Here is a small sample code that does that.
       ------
       import java.applet.*;
       import java.awt.*;

       public class simpleApplet1 extends Applet {
         TextField text;

         public simpleApplet1() {
               text = new TextField(20);
               add( text );
         }

         /*
          .... applet stuff comes here ...
         */

         public static void main( String args[] ) {
           simpleApplet1 ap = new simpleApplet1();
           frameApplet fr = new frameApplet(ap);
           fr.resize(200,100);
           fr.show();
           ap.init();
           ap.start();
         }
       }


       class frameApplet extends Frame {
         public frameApplet( Applet ap ) {
           add(ap);
         }
       }
---------
This applet can be run as an applet or as a stand alone.
Hope that helps.
G.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now