Applet not initialized


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Applet not initialized

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    55

    Applet not initialized

    I have compiled the following code and it compiles but when i run the code the following error message is shown in the applet window Start: Applet not initialized. Can someone have a look at my code and say where I went wrong. Thanks

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JApplet;
    /*
    * Created on Feb 12, 2005
    *
    */

    /**
    * @author trixma
    * @version 1.0
    */
    public class IPClassFinder extends JApplet {
    private Container container;
    private JLabel ipClass, header, title, fullstop, fullstop1, fullstop2;
    private JButton calculate, clear;
    private JTextField field1, field2, field3, field4, field5;

    public void init() {

    container = getContentPane();

    JPanel border = new JPanel(new BorderLayout(5,5));

    header = new JLabel("IP address information", JLabel.CENTER);
    border.add(header);

    JPanel grid1 = new JPanel();
    grid1.setLayout(new GridLayout(2,8,1,5));

    title = new JLabel("Enter IP Address", JLabel.CENTER);
    grid1.add(title);

    field1 = new JTextField(3);
    grid1.add(field1);

    fullstop = new JLabel(".", JLabel.CENTER);
    grid1.add(fullstop);

    field2 = new JTextField(3);
    grid1.add(field2);

    fullstop1 = new JLabel(".", JLabel.CENTER);
    grid1.add(fullstop1);

    field3 = new JTextField(3);
    grid1.add(field3);

    fullstop2 = new JLabel(".", JLabel.CENTER);
    grid1.add(fullstop2);

    field4 = new JTextField(3);
    grid1.add(field4);

    ipClass = new JLabel("IP Address Class");
    grid1.add(ipClass);

    field5 = new JTextField();
    grid1.add(field5);

    border.add("CENTER", grid1);

    JPanel grid2 = new JPanel(new GridLayout(1,2,5,5));

    calculate = new JButton("Calculate");
    grid2.add(calculate);

    clear = new JButton("Clear");
    grid2.add(clear);

    border.add("South", grid2);

    container.add(border);

    }
    }

  2. #2
    Join Date
    Feb 2005
    Posts
    55

    fixed problem

    Below is the solution to the above problem.

    JPanel border = new JPanel(new BorderLayout(5,5)); <-- deleted this line

    border.add(header); <- this line should be container.add(header, BorderLayout.NORTH);

    border.add("CENTER", grid1); <- This line should be container.add(grid1, BorderLayout.CENTER);

    border.add("South", grid2); <- This line should be container.add(grid2, BorderLayout.SOUTH);

    container.add(border); <- deleted this line

  3. #3
    Join Date
    Feb 2005
    Posts
    3
    also, you may delete import javax.swing.JApplet; as it is already imported via import javax.swing.*;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center