1

当我执行与我的小程序关联的 HTML 文件时,没有绘制任何内容并且屏幕为空。为什么会这样?如何将字符串添加到 Applet 中?

Java 小程序的源代码:

package m2mcom.web;
import m2mcom.entities.AutomatedTelnetClient;
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class Displaytext extends JApplet {
//Called when this applet is loaded into the browser.
public void init() {
    //Execute a job on the event-dispatching thread; creating this applet's GUI.
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                AutomatedTelnetClient telnet = new AutomatedTelnetClient();
                String answer = telnet.request();
                JLabel lbl = new JLabel(answer);
                add(lbl);
            }
        });
    } catch (Exception e) {
        System.err.println("createGUI didn't complete successfully");
    }
}
}
4

0 回答 0