Getting Applet not initialized error

最后都变了- 提交于 2020-01-05 08:00:34

问题


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();
}
 }

回答1:


This is Not an Applet. I think you need to check out the Life cycle of an Applet Here:

http://docs.oracle.com/javase/tutorial/deployment/applet/lifeCycle.html




回答2:


This class is not launching as an applet as it does not extend JApplet or 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.

Rather than using the old heavyweight AWT, use lightweight Swing. Also look at Java Web Start for deployment.



来源:https://stackoverflow.com/questions/16460760/getting-applet-not-initialized-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!