Solved

How do I debug a java applet?

Posted on 1998-03-19
5
192 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

777 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