如何从一个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
....
}
答案 0 :(得分:1)
您可以使用构造函数实例化任何其他类的applet。为了使这个类可以用作applet,它应该有一个无参数的构造函数,所以你可以简单地写
Hangman h = new Hangman();
但是为了让您的applet正常工作,您可能需要将其放入applet容器中,或者模拟它。