Solved

How do I debug a java applet?

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is Applet the way to go for my drag and drop system? 8 51
java imports not found 4 71
Print Rhino Java Array in Javascript 1 58
Is there a Google Voice API? 9 75
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

752 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