Экземпляр JApplet - PullRequest
       4

Экземпляр JApplet

0 голосов
/ 30 мая 2011

Как я могу получить в java-классе экземпляр из класса, выходящий из jApplet Благодарю. это ярлык класса

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 secretWordLen;
    /* 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 
....
}

1 Ответ

1 голос
/ 30 мая 2011

Вы можете создать экземпляр апплета, как и любой другой класс, с помощью конструктора.Чтобы этот класс можно было использовать в качестве апплета, он должен иметь конструктор без аргументов, поэтому вы можете просто написать

Hangman h = new Hangman();

Но для правильной работы вашего апплета вам, вероятно, нужно поместить его в апплетконтейнер, или подражать такому.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...