问题
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