开发者

JApplet instance

How can I get in a java class an instance from a class extends from jApplet Thanks. this is a shortcut of class

public class Hangman
        extends java.applet.Applet
        implements Runnable, MouseListener, KeyListener {

    /* This is the maximum number of incorrect guesses. */
    final int maxTries = 5;
    /* This is the maximum length of a secret word. */
    final int maxWordLen = 20;
    /* This buffer holds the letters in the secret word. */
    char secretWord[];
    /* This is the length of the secret word. */
    int secretWordLe开发者_JAVA百科n;
    /* This buffer holds the letters which the user typed
    but don't appear in the secret word. */
    char wrongLetters[];
    /* This is the current number of incorrect guesses. */
    int wrongLettersCount;
    /* This buffer holds letters that the user has successfully
    guessed. */
    char word[];
    /* Number of correct 
....
}


You can instantiate an applet like any other class, with the constructor. For this class to be usable as an applet, it should have a no-argument constructor, so you can simply write

Hangman h = new Hangman();

But for your applet to properly work, you probably need to put it into an applet container, or emulate such.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜