Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I debug a java applet?

Posted on 1998-03-19
5
Medium Priority
?
202 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 80 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

963 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