Results 1 to 2 of 2
  1. #1
    Nivedita123 is offline Member
    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    Default Null Pointer Exception in java applets...

    I have been working on a project and I m getting a NullPointerException in this part:

    Code:

    import java.awt.*;
    import java.awt.event.*;
    import java.sql.Connection;
    import javax.swing.*;

    public class home extends JFrame implements ActionListener
    {
    JLabel jl=new JLabel("",new ImageIcon("abc.gif"),JLabel.CENTER);
    JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12;
    JButton b1,b2,b3;
    JTextField t1,t2,t5,t4,t7;
    JPasswordField t3,t6;
    JComboBox<String> jc1;

    public home(String str)
    {
    super(str);
    setSize(1360,768);

    setLayout(new FlowLayout());
    setLocationRelativeTo(this);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setResizable(false);


    Font mainFont = new Font ("Cooper Black", Font.PLAIN, 24);
    Font subFont = new Font ("Berlin Sans FB", Font.PLAIN, 20);
    Font nrmlFont = new Font ("Arial", Font.PLAIN, 18);

    l5=new JLabel("Quiz System");
    l5.setForeground(Color.RED);
    l5.setFont (mainFont);
    l5.setLocation(700,0);
    add(l5);

    l1= new JLabel("Existing user? Login Here:");
    l1.setLocation(150,70);
    l1.setForeground(Color.BLUE);
    l1.setFont (subFont);
    add(l1);

    l2=new JLabel("Enter username:");
    l2.setFont(nrmlFont);
    l2.setLocation(100,100);
    add(l2);

    t1=new JTextField(15);
    t1.setLocation(200,100);
    add(t2);

    l12=new JLabel("Select user type:");
    l12.setFont(nrmlFont);
    l12.setLocation(400,100);
    add(l12);

    String str1[]={"Admin","User"};
    jc1= new JComboBox<String>(str1);
    jc1.setLocation(550,100);
    // jc1.addItemListener( this);
    add(jl);

    l3=new JLabel("Enter password:");
    l3.setLocation(100,130);
    l3.setFont(nrmlFont);
    add(l3);

    t3=new JPasswordField(15);
    t3.setLocation(200,130);
    add(t3);

    b1=new JButton("Submit");
    b1.addActionListener(this);
    b1.setLocation(200,170);
    add(b1);

    l6=new JLabel("New user? Sign up Here: (Note: Admin approval will be needed!)");
    l6.setForeground(Color.BLUE);
    l6.setFont (subFont);
    l6.setLocation(150,210);
    add(l6);

    l7=new JLabel("First name:");
    l7.setFont(nrmlFont);
    l7.setLocation(100,240);
    add(l7);

    t2=new JTextField(15);
    t2.setLocation(200,240);
    add(t2);

    l8=new JLabel("Last name:");
    l8.setFont(nrmlFont);
    l8.setLocation(100,270);
    add(l8);

    t4=new JTextField(15);
    t4.setLocation(200,270);
    add(t4);

    l9=new JLabel("Username:");
    l9.setFont(nrmlFont);
    l9.setLocation(100,300);
    add(l9);

    t5=new JTextField(15);
    t5.setLocation(200,300);
    add(t5);

    l10=new JLabel("New password:");
    l10.setFont(nrmlFont);
    l10.setLocation(100,330);
    add(l10);

    t6=new JPasswordField(15);
    t6.setLocation(200,330);
    add(t6);

    l11=new JLabel("Email-id:");
    l11.setFont(nrmlFont);
    l11.setLocation(100,360);
    add(l11);

    t7=new JTextField(15);
    t7.setLocation(200,360);
    add(t7);

    b2=new JButton("Continue");
    b2.setLocation(200,390);
    b2.addActionListener(this);
    add(b2);

    JLabel l13=new JLabel();
    Icon obj=new ImageIcon("RAT2.jpg");
    l13=new JLabel(obj);
    l13.setLocation(500,100);
    add(l13);

    }

    public static void main(String args[])
    {
    home obj=new home("Home Page");
    obj.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent ae)
    {
    String dt="Done";
    String dm="Your details have been submitted. You will be able to login as soon as approoved by admin!!";
    int dty=JOptionPane.INFORMATION_MESSAGE;
    if(ae.getSource()==b1)
    {

    //some code

    }

    if(ae.getSource()==b2)
    {
    JOptionPane.showMessageDialog((Component)null,dm,d t,dty);

    }
    }
    }



    Exception:




    Can anyone tell me what m i doing wrong?

    P.S. I m using eclipse. Thanx in advance

  2. #2
    Daryn is offline Senior Member
    Join Date
    Oct 2012
    Posts
    176
    Rep Power
    3

    Default Re: Null Pointer Exception in java applets...

    Can you please wrap you code in code tags and also what line does it say the null point exception is on
    With the right know how, anything is possible

Similar Threads

  1. Null pointer Exception
    By aortell24 in forum New To Java
    Replies: 5
    Last Post: 07-21-2012, 12:38 AM
  2. Null pointer exception
    By DBaskov in forum New To Java
    Replies: 14
    Last Post: 07-11-2011, 12:16 AM
  3. Null Pointer exception (Again !!)
    By mobosecomin in forum New To Java
    Replies: 6
    Last Post: 03-29-2011, 06:04 PM
  4. Null pointer exception
    By Domo230 in forum New To Java
    Replies: 4
    Last Post: 02-28-2011, 11:21 AM
  5. JAVA SOUND API's NULL POINTER EXCEPTION
    By ank64 in forum New To Java
    Replies: 14
    Last Post: 08-10-2010, 12:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •