Hello everyone,
Im new to this forum and sort of new to Java aswell. I'd like to ask you to comment on the way I practise Java and also hopefully solve this "Start: Applet not initialized." error. I have not tried to run this through browsers because i didn't create the html yet but i am using an applet viewer instead.
At this step i am only attempting to do the layout of the log in screen of the program and nothing is happening behind the curtain. and other than the error i get on the applet viewer Start: Applet not initialized." i also get the following code at the compiler after attempting to run the applet

    at Window.init(Window.java:34)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
And here is my humble code...
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;

import javax.swing.*;
//import javax.swing.JApplet;
//import javax.swing.JButton;
//import javax.swing.JLabel;
//import javax.swing.JPanel;
//import javax.swing.JPasswordField;
//import javax.swing.JTextField;

public class Window extends JApplet{

    private Container windowC;
    private JPanel logInPan, bannerPan, cpPan, bottomPan, logMidPan;
    private JTextField inName = new JTextField(15);
    private JPasswordField inPass = new JPasswordField();
    private JButton loginB = new JButton("Log In");
    private JButton signUpB = new JButton("Sign Up");
    private JButton forgotB = new JButton("Forgot your Password?");
    private JLabel welcomeL = new JLabel("Welcome to Firm 5 System");
    private JLabel infoL = new JLabel("Please Enter your details to access your account.");
    private JLabel nameL = new JLabel("UserName");
    private JLabel passL = new JLabel("Password");

    public void init(){

        windowC = getContentPane();
        GridLayout mainLay = new GridLayout(2,1);
        GridLayout bottomLay = new GridLayout(1,2);

        logInPan.setLayout(new GridLayout(4,1));
        logMidPan.setLayout(new GridLayout(3,2));


        logInPan.add(welcomeL, BorderLayout.NORTH);
        logInPan.add(logMidPan, BorderLayout.CENTER);
        logInPan.add(forgotB, BorderLayout.SOUTH);


        windowC.setSize(1024, 768);


I'd be grateful with any constructive critism which can help me improve and grateful x2 for helping me find out why this error is happening

Recommended Answers

All 4 Replies

You are probably getting the "not initialised" because your init method is terminating abnormally (with an NPE exception).
The NPE means an uninitialised variable. Your line numbers don't seem to match the error message exactly, but at a guess it's probably due to your not initialising yout JPanel variables.

The style looks perfectly OK to me.

@JamesCherrill I have commented out 6 lines on top which i removed while i was inserting it to this page, i havve just fixed it

OK, that fits. Uninitialised JPanels.

ouch, im ashamed, didnt realise at all, thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.