Solved

How do I debug a java applet?

Posted on 1998-03-19
5
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

617 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