获取Applet未初始化错误 [英] Getting Applet not initialized error
问题描述
在我的程序中一切都正确吗?
当我运行它时,会出现一个屏幕,但显示未初始化Applet
is everything is right in my programme??
When i run it the a screen appears but it says that Applet is not initialized
import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
public class JobseekerLogin extends Frame {
public void CreateFrame(){
Frame frame = new Frame("Frame in Java Swing");
frame.setSize(400, 400);
frame.setVisible(true);
Label lb = new Label("Username");
add("East",lb);
add("West",new TextArea(""));
Label lb1 = new Label("Password");
add("East",lb1);
add("West",new TextArea(""));
}
public static void main(String []args){
JobseekerLogin obj = new JobseekerLogin();
obj.CreateFrame();
}
}
推荐答案
该类未作为applet启动,因为它没有扩展JApplet
或Applet
.
This class is not launching as an applet as it does not extend JApplet
or Applet
.
即使已解决此问题,小程序客户端中也不会出现任何内容. Applet不调用main
方法,而是调用init
.另外,不要为applet组件创建新的Frame
-将它们添加到applet容器本身.
Even when this is fixed, nothing will appear in the applet client. Applets do not call the main
method but rather init
. Also don't create a new Frame
for applet components - add them to the applet container itself.
使用轻型Swing
,而不是使用旧的重量级AWT.还要查看 Java Web Start 进行部署.
Rather than using the old heavyweight AWT, use lightweight Swing
. Also look at Java Web Start for deployment.
这篇关于获取Applet未初始化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!