Null Pointer Exception, don't know why...

Hi everyone,
This may well be really simple, but it's driving me crazy...
The program puts lots of panels into other panels and when a combo box is set to a certain value the number of panels alters.
Here is some of the code:
             *  Fourth User
            // First user main panel
            pn_u4 = new JPanel();
            pn_u4.setLayout( new BorderLayout(5,5) );
            pn_u4.setPreferredSize( new Dimension(800,80) );
            pn_u4.setBackground(Color.WHITE);
            // First user top panel that goes into the
            // main panel North
            pn_u4T = new JPanel();
            pn_u4T.setLayout( new BorderLayout(5,5) );
            pn_u4T.setPreferredSize( new Dimension(800,40) );
            pn_u4T.setBackground(Color.WHITE);
            // First user bottom panel that goes into the
            // main panel South
            pn_u4B = new JPanel();
            pn_u4B.setLayout( new BorderLayout(5,5) );
            pn_u4B.setPreferredSize( new Dimension(800,40) );
            pn_u4B.setBackground(Color.WHITE);
            // First user top panel left, goes into the
            // top panel West
            pn_u4TL = new JPanel();
            pn_u4TL.setLayout( new FlowLayout() );
            pn_u4TL.setPreferredSize( new Dimension(400,40) );
            pn_u4TL.setBackground(Color.WHITE);
                lbl_u4Name = new JLabel("Name");
                lbl_u4Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u4Name = new JTextField(28);
            pn_u4TL.add(lbl_u4Name);
            pn_u4TL.add(tf_u4Name);
            // First user top panel right, goes into the
            // top panel East
            pn_u4TR = new JPanel();
            pn_u4TR.setLayout( new FlowLayout() );
            pn_u4TR.setPreferredSize( new Dimension(400,40) );
            pn_u4TR.setBackground(Color.WHITE);
                lbl_u4ID = new JLabel("GNAS ID");
                lbl_u4ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u4ID = new JTextField(28);
            pn_u4TR.add(lbl_u4ID);
            pn_u4TR.add(tf_u4ID);
            pn_u4T.add(pn_u4TL, BorderLayout.WEST);
            pn_u4T.add(pn_u4TR, BorderLayout.EAST);
            // First user bottom panel left, goes into the
            // bottom panel West
            pn_u4BL = new JPanel();
            pn_u4BL.setLayout( new FlowLayout() );
            pn_u4BL.setPreferredSize( new Dimension(400,40) );
            pn_u4BL.setBackground(Color.WHITE);
                lbl_u4Round = new JLabel("Round Name");
                lbl_u4Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u4Round = new JTextField(24);
            pn_u4BL.add(lbl_u4Round);
            pn_u4BL.add(tf_u4Round);
            // First user bottom panel right, goes into the
            // bottom panel East
            pn_u4BR = new JPanel();
            pn_u4BR.setLayout( new FlowLayout() );
            pn_u4BR.setPreferredSize( new Dimension(400,40) );
            pn_u4BR.setBackground(Color.WHITE);
                lbl_u4Bow = new JLabel("Bow Type                                                ");
                lbl_u4Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                cb_u4Bow = new JComboBox();
                cb_u4Bow.addActionListener(this);
                    cb_u4Bow.addItem("    Compound    ");
                    cb_u4Bow.addItem("    Long Bow    ");
                    cb_u4Bow.addItem("    Recurve     ");
            pn_u4BR.add(lbl_u4Bow);
            pn_u4BR.add(cb_u4Bow);
            pn_u4B.add(pn_u4BL, BorderLayout.WEST);
            pn_u4B.add(pn_u4BR, BorderLayout.EAST);
            pn_u4.add(pn_u4T, BorderLayout.NORTH);
            pn_u4.add(pn_u4B, BorderLayout.SOUTH);
            //pn_u3u4.add(pn_u4, BorderLayout.NORTH);
            pn_2.add(pn_u1u2, BorderLayout.NORTH);
            pn_2.add(pn_u3u4, BorderLayout.SOUTH);           
            //initialWindow.add(pn_topAll);//BorderLayout.NORTH);
            initialWindow.add(pn_topAll, BorderLayout.NORTH);
            initialWindow.add(pn_2, BorderLayout.CENTER);
           pack();    There are a total of four users, but too much code to paste here,
Now there's the event listener:
public void actionPerformed(ActionEvent e)
            if (e.getSource() == cb_noOfPeople)
                if(cb_noOfPeople.getSelectedItem() == "  1  ")
***                if(pn_u3u4.getComponentCount() > 0)
                        pn_u3u4.remove(pn_u3);
                        pn_u3u4.remove(pn_u4);
                    else
                    if(pn_u1u2.getComponentCount() == 2)
                        pn_u1u2.remove(pn_u2);
                    else
                    initialWindow.repaint();
                    initialWindow.validate();
                else if(cb_noOfPeople.getSelectedItem() == "  2  ")
                    if(pn_u3u4.getComponentCount() > 0)
                        pn_u3u4.remove(pn_u3);
                        pn_u3u4.remove(pn_u4);
                    else
                    pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
                    initialWindow.repaint();
                    initialWindow.validate();
                else if(cb_noOfPeople.getSelectedItem() == "  3  ")
                    if(pn_u3u4.getComponentCount() == 2)
                        pn_u3u4.remove(pn_u4);
                    else
                    pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
                    pn_u3u4.add(pn_u3, BorderLayout.NORTH);
                    initialWindow.repaint();
                    initialWindow.validate();
                else if(cb_noOfPeople.getSelectedItem() == "  4  ")
                    pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
                    pn_u3u4.add(pn_u3, BorderLayout.NORTH);
                    pn_u3u4.add(pn_u4, BorderLayout.SOUTH);
                    initialWindow.repaint();
                    initialWindow.validate();
                else
            }Everything works until it reaches:
***     if(pn_u3u4.getComponentCount() > 0)
                        pn_u3u4.remove(pn_u3);
                        pn_u3u4.remove(pn_u4);
                    else
                    if(pn_u1u2.getComponentCount() == 2)
                        pn_u1u2.remove(pn_u2);
                    else
                    }(please ignore the three stars, just to indicate where that code was)
Wihout the above bit of code inplace everything works fine, I can change the value of the combo box and things are removed and added, but when I add the above if statements to the value "1" area, i get the null pointer, which doesn't make sence to me.
Exception in thread "main" java.lang.NullPointerException
at InitialScreen.actionPerformed(InitialScreen.java:601)
Thanks for help in advance (I can provide all 600 lines of code if needed)
Victoria

Your actionListener for your cb_noOfPeople is being fired before the rest of the components are being initialized. I just moved the addition of the actionListener to right before the pack() statement to ensure that all of your variables get initialized and it works like a charm. Here you go:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.*;
*  @author Victoria
*  @version v1.01
*  Start date 29th Nov 06
class InitialScreen extends JFrame implements ActionListener
     Container initialWindow;
     JLabel titleBar, lbl_noOfUsers, lbl_u1Name, lbl_u1ID, lbl_u1Bow, lbl_u1Round, lbl_u2Name, lbl_u2ID, lbl_u2Bow, lbl_u2Round, lbl_u3Name, lbl_u3ID, lbl_u3Round, lbl_u3Bow, lbl_u4Name, lbl_u4ID, lbl_u4Round, lbl_u4Bow;
        JComboBox cb_noOfPeople, cb_u1Bow, cb_u2Bow, cb_u3Bow, cb_u4Bow;
        JTextField tf_u1Name, tf_u1ID, tf_u1Round, tf_u2Name, tf_u2ID, tf_u2Round, tf_u3Name, tf_u3ID, tf_u3Round, tf_u4Name, tf_u4ID, tf_u4Round, tf_compDate, tf_compTime, tf_compID;
        JPanel pn_1, pn_2, pn_3, pn_u1u2, pn_u3u4, pn_top, pn_top2, pn_top3, pn_topAll, pn_u1, pn_u1T, pn_u1TL, pn_u1TR, pn_u1B, pn_u1BL, pn_u1BR, pn_u2, pn_u2T, pn_u2TL, pn_u2TR, pn_u2B, pn_u2BL, pn_u2BR, pn_u3, pn_u3T, pn_u3TL, pn_u3TR, pn_u3B, pn_u3BL, pn_u3BR, pn_u4, pn_u4T, pn_u4TL, pn_u4TR, pn_u4B, pn_u4BL, pn_u4BR, pn_shootInfo, pn_button;
     JButton but_go, but_reset, but_exit;
         *  Constructor for the initial screen
     public InitialScreen()
            //  Create a window pane called initial Window
            //  and set it to a preferred size of 800x600
            initialWindow = getContentPane();
            initialWindow.setLayout( new BorderLayout(5,5) );
            setPreferredSize( new Dimension(800,600) );
            initialWindow.setBackground(Color.WHITE);
            //pn_1 = new JPanel();
            //pn_1.setLayout( new BorderLayout(5,5) );
            //pn_1.setPreferredSize( new Dimension(800,40) );
            //pn_1.setBackground(Color.WHITE);
            pn_2 = new JPanel();
            pn_2.setLayout( new BorderLayout(5,5) );
            pn_2.setPreferredSize( new Dimension(800,40) );
            pn_2.setBackground(Color.WHITE);
            //pn_3 = new JPanel();
            //pn_3.setLayout( new BorderLayout(5,5) );
            //pn_3.setPreferredSize( new Dimension(800,40) );
            //pn_3.setBackground(Color.WHITE);
            // First top panel just houese the label that
            // says what the program is and fill in info
            pn_top = new JPanel();
            pn_top.setLayout( new BorderLayout(5,5) );
            pn_top.setPreferredSize( new Dimension(800,40) );
            pn_top.setBackground(Color.WHITE);
                titleBar = new JLabel("Archery Scoring Program - Please fill in the following information \n ", JLabel.CENTER);
                titleBar.setFont( new Font("Times New Roman",Font.PLAIN,20) );
            //pn_top.add(titleBar, BorderLayout.NORTH);
            //pn_top.add(lbl_noOfUsers, BorderLayout.WEST);
            //pn_top.add(cb_noOfPeople, BorderLayout.EAST);
            pn_top.add(titleBar);
            // Second panel contains the how many people
            // ComboBox
            pn_top2 = new JPanel();
            pn_top2.setLayout(new FlowLayout());
            pn_top2.setPreferredSize( new Dimension(360,40) );
            pn_top2.setBackground(Color.WHITE);
                lbl_noOfUsers = new JLabel("No of members shooting on this target");
                lbl_noOfUsers.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                cb_noOfPeople = new JComboBox();
                //cb_noOfPeople.addActionListener(this);
                    cb_noOfPeople.addItem("  1  ");
                    cb_noOfPeople.addItem("  2  ");
                    cb_noOfPeople.addItem("  3  ");
                    cb_noOfPeople.addItem("  4  ");
            pn_top2.add(lbl_noOfUsers);
            pn_top2.add(cb_noOfPeople);
            // Third panel contains nothing but alligns
            // the second panel correctly
            pn_top3 = new JPanel();
            pn_top3.setLayout( new FlowLayout() );
            pn_top3.setPreferredSize( new Dimension(440,40) );
            pn_top3.setBackground(Color.WHITE);
            // Last top panel contains all the previous
            // top panels and adds the other top
            // panels to it
            pn_topAll = new JPanel();
            pn_topAll.setLayout( new BorderLayout(5,5) );
            //pn_topAll.setPreferredSize( new Dimension(450,100) );
            pn_topAll.setBackground(Color.WHITE);
            pn_topAll.add(pn_top, BorderLayout.NORTH);
            pn_topAll.add(pn_top2, BorderLayout.WEST);
            pn_topAll.add(pn_top3, BorderLayout.EAST);
            pn_u1u2 = new JPanel();
            pn_u1u2.setLayout( new BorderLayout(5,5) );
            pn_u1u2.setPreferredSize( new Dimension(800,160) );
            pn_u1u2.setBackground(Color.WHITE);
             *  First User
             *  As long as the if statement is correctly working
             *  The first user panel will be added upon load
             *  User two, three and four will be added depending on
             *  the value of the combobox which asks how many
             *  users are shooting on the target
            // First user main panel
            pn_u1 = new JPanel();
            pn_u1.setLayout( new BorderLayout(5,5) );
            pn_u1.setPreferredSize( new Dimension(800,80) );
            pn_u1.setBackground(Color.WHITE);
            // First user top panel that goes into the
            // main panel North
            pn_u1T = new JPanel();
            pn_u1T.setLayout( new BorderLayout(5,5) );
            pn_u1T.setPreferredSize( new Dimension(800,40) );
            pn_u1T.setBackground(Color.WHITE);
            // First user bottom panel that goes into the
            // main panel South
            pn_u1B = new JPanel();
            pn_u1B.setLayout( new BorderLayout(5,5) );
            pn_u1B.setPreferredSize( new Dimension(800,40) );
            pn_u1B.setBackground(Color.WHITE);
            // First user top panel left, goes into the
            // top panel West
            pn_u1TL = new JPanel();
            pn_u1TL.setLayout( new FlowLayout() );
            pn_u1TL.setPreferredSize( new Dimension(400,40) );
            pn_u1TL.setBackground(Color.WHITE);
                lbl_u1Name = new JLabel("Name");
                lbl_u1Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u1Name = new JTextField(28);
            pn_u1TL.add(lbl_u1Name);
            pn_u1TL.add(tf_u1Name);
            // First user top panel right, goes into the
            // top panel East
            pn_u1TR = new JPanel();
            pn_u1TR.setLayout( new FlowLayout() );
            pn_u1TR.setPreferredSize( new Dimension(400,40) );
            pn_u1TR.setBackground(Color.WHITE);
                lbl_u1ID = new JLabel("GNAS ID");
                lbl_u1ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u1ID = new JTextField(28);
            pn_u1TR.add(lbl_u1ID);
            pn_u1TR.add(tf_u1ID);
            pn_u1T.add(pn_u1TL, BorderLayout.WEST);
            pn_u1T.add(pn_u1TR, BorderLayout.EAST);
            // First user bottom panel left, goes into the
            // bottom panel West
            pn_u1BL = new JPanel();
            pn_u1BL.setLayout( new FlowLayout() );
            pn_u1BL.setPreferredSize( new Dimension(400,40) );
            pn_u1BL.setBackground(Color.WHITE);
                lbl_u1Round = new JLabel("Round Name");
                lbl_u1Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u1Round = new JTextField(24);
            pn_u1BL.add(lbl_u1Round);
            pn_u1BL.add(tf_u1Round);
            // First user bottom panel right, goes into the
            // bottom panel East
            pn_u1BR = new JPanel();
            pn_u1BR.setLayout( new FlowLayout() );
            pn_u1BR.setPreferredSize( new Dimension(400,40) );
            pn_u1BR.setBackground(Color.WHITE);
                lbl_u1Bow = new JLabel("Bow Type                                                ");
                lbl_u1Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                cb_u1Bow = new JComboBox();
                cb_u1Bow.addActionListener(this);
                    cb_u1Bow.addItem("    Compound    ");
                    cb_u1Bow.addItem("    Long Bow    ");
                    cb_u1Bow.addItem("    Recurve     ");
            pn_u1BR.add(lbl_u1Bow);
            pn_u1BR.add(cb_u1Bow);
            pn_u1B.add(pn_u1BL, BorderLayout.WEST);
            pn_u1B.add(pn_u1BR, BorderLayout.EAST);
            pn_u1.add(pn_u1T, BorderLayout.NORTH);
            pn_u1.add(pn_u1B, BorderLayout.SOUTH);
            pn_u1u2.add(pn_u1, BorderLayout.NORTH);
             *  Second User
            // First user main panel
            pn_u2 = new JPanel();
            pn_u2.setLayout( new BorderLayout(5,5) );
            pn_u2.setPreferredSize( new Dimension(800,80) );
            pn_u2.setBackground(Color.WHITE);
            // First user top panel that goes into the
            // main panel North
            pn_u2T = new JPanel();
            pn_u2T.setLayout( new BorderLayout(5,5) );
            pn_u2T.setPreferredSize( new Dimension(800,40) );
            pn_u2T.setBackground(Color.WHITE);
            // First user bottom panel that goes into the
            // main panel South
            pn_u2B = new JPanel();
            pn_u2B.setLayout( new BorderLayout(5,5) );
            pn_u2B.setPreferredSize( new Dimension(800,40) );
            pn_u2B.setBackground(Color.WHITE);
            // First user top panel left, goes into the
            // top panel West
            pn_u2TL = new JPanel();
            pn_u2TL.setLayout( new FlowLayout() );
            pn_u2TL.setPreferredSize( new Dimension(400,40) );
            pn_u2TL.setBackground(Color.WHITE);
                lbl_u2Name = new JLabel("Name");
                lbl_u2Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u2Name = new JTextField(28);
            pn_u2TL.add(lbl_u2Name);
            pn_u2TL.add(tf_u2Name);
            // First user top panel right, goes into the
            // top panel East
            pn_u2TR = new JPanel();
            pn_u2TR.setLayout( new FlowLayout() );
            pn_u2TR.setPreferredSize( new Dimension(400,40) );
            pn_u2TR.setBackground(Color.WHITE);
                lbl_u2ID = new JLabel("GNAS ID");
                lbl_u2ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u2ID = new JTextField(28);
            pn_u2TR.add(lbl_u2ID);
            pn_u2TR.add(tf_u2ID);
            pn_u2T.add(pn_u2TL, BorderLayout.WEST);
            pn_u2T.add(pn_u2TR, BorderLayout.EAST);
            // First user bottom panel left, goes into the
            // bottom panel West
            pn_u2BL = new JPanel();
            pn_u2BL.setLayout( new FlowLayout() );
            pn_u2BL.setPreferredSize( new Dimension(400,40) );
            pn_u2BL.setBackground(Color.WHITE);
                lbl_u2Round = new JLabel("Round Name");
                lbl_u2Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u2Round = new JTextField(24);
            pn_u2BL.add(lbl_u2Round);
            pn_u2BL.add(tf_u2Round);
            // First user bottom panel right, goes into the
            // bottom panel East
            pn_u2BR = new JPanel();
            pn_u2BR.setLayout( new FlowLayout() );
            pn_u2BR.setPreferredSize( new Dimension(400,40) );
            pn_u2BR.setBackground(Color.WHITE);
                lbl_u2Bow = new JLabel("Bow Type                                                ");
                lbl_u2Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                cb_u2Bow = new JComboBox();
                cb_u2Bow.addActionListener(this);
                    cb_u2Bow.addItem("    Compound    ");
                    cb_u2Bow.addItem("    Long Bow    ");
                    cb_u2Bow.addItem("    Recurve     ");
            pn_u2BR.add(lbl_u2Bow);
            pn_u2BR.add(cb_u2Bow);
            pn_u2B.add(pn_u2BL, BorderLayout.WEST);
            pn_u2B.add(pn_u2BR, BorderLayout.EAST);
            pn_u2.add(pn_u2T, BorderLayout.NORTH);
            pn_u2.add(pn_u2B, BorderLayout.SOUTH);
            //pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
            pn_u3u4 = new JPanel();
            pn_u3u4.setLayout( new BorderLayout(5,5) );
            pn_u3u4.setPreferredSize( new Dimension(800,160) );
            pn_u3u4.setBackground(Color.WHITE);
             *  Third User
            // First user main panel
            pn_u3 = new JPanel();
            pn_u3.setLayout( new BorderLayout(5,5) );
            pn_u3.setPreferredSize( new Dimension(800,80) );
            pn_u3.setBackground(Color.WHITE);
            // First user top panel that goes into the
            // main panel North
            pn_u3T = new JPanel();
            pn_u3T.setLayout( new BorderLayout(5,5) );
            pn_u3T.setPreferredSize( new Dimension(800,40) );
            pn_u3T.setBackground(Color.WHITE);
            // First user bottom panel that goes into the
            // main panel South
            pn_u3B = new JPanel();
            pn_u3B.setLayout( new BorderLayout(5,5) );
            pn_u3B.setPreferredSize( new Dimension(800,40) );
            pn_u3B.setBackground(Color.WHITE);
            // First user top panel left, goes into the
            // top panel West
            pn_u3TL = new JPanel();
            pn_u3TL.setLayout( new FlowLayout() );
            pn_u3TL.setPreferredSize( new Dimension(400,40) );
            pn_u3TL.setBackground(Color.WHITE);
                lbl_u3Name = new JLabel("Name");
                lbl_u3Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u3Name = new JTextField(28);
            pn_u3TL.add(lbl_u3Name);
            pn_u3TL.add(tf_u3Name);
            // First user top panel right, goes into the
            // top panel East
            pn_u3TR = new JPanel();
            pn_u3TR.setLayout( new FlowLayout() );
            pn_u3TR.setPreferredSize( new Dimension(400,40) );
            pn_u3TR.setBackground(Color.WHITE);
                lbl_u3ID = new JLabel("GNAS ID");
                lbl_u3ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u3ID = new JTextField(28);
            pn_u3TR.add(lbl_u3ID);
            pn_u3TR.add(tf_u3ID);
            pn_u3T.add(pn_u3TL, BorderLayout.WEST);
            pn_u3T.add(pn_u3TR, BorderLayout.EAST);
            // First user bottom panel left, goes into the
            // bottom panel West
            pn_u3BL = new JPanel();
            pn_u3BL.setLayout( new FlowLayout() );
            pn_u3BL.setPreferredSize( new Dimension(400,40) );
            pn_u3BL.setBackground(Color.WHITE);
                lbl_u3Round = new JLabel("Round Name");
                lbl_u3Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u3Round = new JTextField(24);
            pn_u3BL.add(lbl_u3Round);
            pn_u3BL.add(tf_u3Round);
            // First user bottom panel right, goes into the
            // bottom panel East
            pn_u3BR = new JPanel();
            pn_u3BR.setLayout( new FlowLayout() );
            pn_u3BR.setPreferredSize( new Dimension(400,40) );
            pn_u3BR.setBackground(Color.WHITE);
                lbl_u3Bow = new JLabel("Bow Type                                                ");
                lbl_u3Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                cb_u3Bow = new JComboBox();
                cb_u3Bow.addActionListener(this);
                    cb_u3Bow.addItem("    Compound    ");
                    cb_u3Bow.addItem("    Long Bow    ");
                    cb_u3Bow.addItem("    Recurve     ");
            pn_u3BR.add(lbl_u3Bow);
            pn_u3BR.add(cb_u3Bow);
            pn_u3B.add(pn_u3BL, BorderLayout.WEST);
            pn_u3B.add(pn_u3BR, BorderLayout.EAST);
            pn_u3.add(pn_u3T, BorderLayout.NORTH);
            pn_u3.add(pn_u3B, BorderLayout.SOUTH);
            //pn_u3u4.add(pn_u3, BorderLayout.NORTH);
             *  Fourth User
            // First user main panel
            pn_u4 = new JPanel();
            pn_u4.setLayout( new BorderLayout(5,5) );
            pn_u4.setPreferredSize( new Dimension(800,80) );
            pn_u4.setBackground(Color.WHITE);
            // First user top panel that goes into the
            // main panel North
            pn_u4T = new JPanel();
            pn_u4T.setLayout( new BorderLayout(5,5) );
            pn_u4T.setPreferredSize( new Dimension(800,40) );
            pn_u4T.setBackground(Color.WHITE);
            // First user bottom panel that goes into the
            // main panel South
            pn_u4B = new JPanel();
            pn_u4B.setLayout( new BorderLayout(5,5) );
            pn_u4B.setPreferredSize( new Dimension(800,40) );
            pn_u4B.setBackground(Color.WHITE);
            // First user top panel left, goes into the
            // top panel West
            pn_u4TL = new JPanel();
            pn_u4TL.setLayout( new FlowLayout() );
            pn_u4TL.setPreferredSize( new Dimension(400,40) );
            pn_u4TL.setBackground(Color.WHITE);
                lbl_u4Name = new JLabel("Name");
                lbl_u4Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u4Name = new JTextField(28);
            pn_u4TL.add(lbl_u4Name);
            pn_u4TL.add(tf_u4Name);
            // First user top panel right, goes into the
            // top panel East
            pn_u4TR = new JPanel();
            pn_u4TR.setLayout( new FlowLayout() );
            pn_u4TR.setPreferredSize( new Dimension(400,40) );
            pn_u4TR.setBackground(Color.WHITE);
                lbl_u4ID = new JLabel("GNAS ID");
                lbl_u4ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u4ID = new JTextField(28);
            pn_u4TR.add(lbl_u4ID);
            pn_u4TR.add(tf_u4ID);
            pn_u4T.add(pn_u4TL, BorderLayout.WEST);
            pn_u4T.add(pn_u4TR, BorderLayout.EAST);
            // First user bottom panel left, goes into the
            // bottom panel West
            pn_u4BL = new JPanel();
            pn_u4BL.setLayout( new FlowLayout() );
            pn_u4BL.setPreferredSize( new Dimension(400,40) );
            pn_u4BL.setBackground(Color.WHITE);
                lbl_u4Round = new JLabel("Round Name");
                lbl_u4Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                tf_u4Round = new JTextField(24);
            pn_u4BL.add(lbl_u4Round);
            pn_u4BL.add(tf_u4Round);
            // First user bottom panel right, goes into the
            // bottom panel East
            pn_u4BR = new JPanel();
            pn_u4BR.setLayout( new FlowLayout() );
            pn_u4BR.setPreferredSize( new Dimension(400,40) );
            pn_u4BR.setBackground(Color.WHITE);
                lbl_u4Bow = new JLabel("Bow Type                                                ");
                lbl_u4Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
                cb_u4Bow = new JComboBox();
                cb_u4Bow.addActionListener(this);
                    cb_u4Bow.addItem("    Compound    ");
                    cb_u4Bow.addItem("    Long Bow    ");
                    cb_u4Bow.addItem("    Recurve     ");
            pn_u4BR.add(lbl_u4Bow);
            pn_u4BR.add(cb_u4Bow);
            pn_u4B.add(pn_u4BL, BorderLayout.WEST);
            pn_u4B.add(pn_u4BR, BorderLayout.EAST);
            pn_u4.add(pn_u4T, BorderLayout.NORTH);
            pn_u4.add(pn_u4B, BorderLayout.SOUTH);
            //pn_u3u4.add(pn_u4, BorderLayout.NORTH);
            pn_2.add(pn_u1u2, BorderLayout.NORTH);
            pn_2.add(pn_u3u4, BorderLayout.SOUTH);           
            //initialWindow.add(pn_topAll);//BorderLayout.NORTH);
            initialWindow.add(pn_topAll, BorderLayout.NORTH);
            initialWindow.add(pn_2, BorderLayout.CENTER);
            // Boolean tests, to see if the combobox
            // has been set, and if so how many panels to
            // add to the initialWindow panel
            if(u1 == true)
                //initialWindow.add(pn_u1);
            if(u2 == true)
                pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
                //initialWindow.add(pn_u2);
                initialWindow.repaint();
                initialWindow.validate();
            if(u3 == true)
                pn_u3u4.add(pn_u3, BorderLayout.NORTH);
                //initialWindow.add(pn_u3);
            if(u4 == true)
                pn_u3u4.add(pn_u4, BorderLayout.SOUTH);
                //initialWindow.add(pn_u4);
         cb_noOfPeople.addActionListener(this);
            pack();   
      *  Event listener for the initial screen
         *  Items it's listening to are:
         *  Combo Box - cb_noOfPoeple
      *  quit button
      *  login button
      *  reset button
     public void actionPerformed(ActionEvent e)
            if (e.getSource() == cb_noOfPeople)
                if(cb_noOfPeople.getSelectedItem() == "  1  ")
                    if(pn_u3u4.getComponentCount() > 0)
                        pn_u3u4.remove(pn_u3);
                        pn_u3u4.remove(pn_u4);
                    else
                    if(pn_u1u2.getComponentCount() == 2)
                        pn_u1u2.remove(pn_u2);
                    else
                    initialWindow.repaint();
                    initialWindow.validate();
                else if(cb_noOfPeople.getSelectedItem() == "  2  ")
                    if(pn_u3u4.getComponentCount() > 0)
                        pn_u3u4.remove(pn_u3);
                        pn_u3u4.remove(pn_u4);
                    else
                    pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
                    initialWindow.repaint();
                    initialWindow.validate();
                else if(cb_noOfPeople.getSelectedItem() == "  3  ")
                    if(pn_u3u4.getComponentCount() == 2)
                        pn_u3u4.remove(pn_u4);
                    else
                    pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
                    pn_u3u4.add(pn_u3, BorderLayout.NORTH);
                    initialWindow.repaint();
                    initialWindow.validate();
                else if(cb_noOfPeople.getSelectedItem() == "  4  ")
                    pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
                    pn_u3u4.add(pn_u3, BorderLayout.NORTH);
                    pn_u3u4.add(pn_u4, BorderLayout.SOUTH);
                    initialWindow.repaint();
                    initialWindow.validate();
                else
     public static void main(String[] argv) { new InitialScreen().setVisible(true); }
}

Similar Messages

  • I can't figure out why I'm getting a Null Pointer Exception

    I'm writing a program that calls Bingo numbers. I got that part of the program to work but when I started adding Swing I kept getting a Null Pointer Exception and I don't know how to fix it. The Exception happens on line 15 of class Panel (g = image.getGraphics();). Here is the code for my classes. I'm still not finished with the program and I can't finish it until I know that this issue is resolved.
    package Graphics;
    import java.awt.Graphics;
    import javax.swing.JFrame;
    public class DrawFrame extends JFrame{
         public Panel panel;
         public DrawFrame(int x, int y, String s) {
              super(s);
              this.setBounds(0, 0, x, y);
              this.setResizable(false);
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setPreferredSize(getSize());
              panel = this.getPanel();
              this.getContentPane().add(panel);
              panel.init();
              this.setVisible(true);
         public Graphics getGraphicsEnvironment(){
              return panel.getGraphicsEnvironment();
         Panel getPanel(){
              return new Panel();
    package Graphics;
    import javax.swing.JPanel;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    public class Panel extends JPanel{
         Graphics g;
         Image image;
         public void init() {
              image = this.createImage(this.getWidth(), this.getHeight());
              g = image.getGraphics();
              g.setColor(Color.white);
              g.fillRect(0, 0, this.getWidth(), this.getHeight());
         Graphics getGraphicsEnvironment() {
              return g;
         public void paint(Graphics graph) {
              if (graph == null)
                   return;
              if (image == null) {
                   return;
              graph.drawImage(image, 0, 0, this);
    package Graphics;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    public class Keys extends KeyAdapter{
    public int keyPressed; //creates a variable keyPressed that stores an integer
    public void keyPressed(KeyEvent e) { //creates a KeyEvent from a KeyListner
              keyPressed = e.getKeyCode(); //gets the key from the keyboard
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.event.KeyEvent;
    import Graphics.*;
    public class Bingo {
         static Ball balls[][] = new Ball[5][15]; //creates a 2D 5 by 15 array
         public static void main(String[] args) {
              DrawFrame frame = new DrawFrame(1500, 500, "Welcome to the automated Bingo Caller."); //creates instance of DrawFrame that is 1000 pixels wide and 500 pixels high
              Graphics g = frame.getGraphicsEnvironment(); //calls the getGraphicsEnvironment method in the DrawFrame class
              Keys key = new Keys(); //creates instance of the Key class
              frame.addKeyListener(key); //adds a KeyListener called Key
              for (int x = 0; x < 5; x++) { //fills rows
                   for (int y = 0; y < 15; y++) { //fills columns
                        balls[x][y] = new Ball(x, y+1); //fills array
              frame.pack(); //adjusts the size of the frame so everything fits
              g.setColor(Color.black); //sets the font color to black
              g.setFont(new Font("MonoSpace", Font.PLAIN, 20)); //creates new font
              for(int y=0;y<balls.length;y++){ //draws all possible balls
                   g.drawString(balls[y][0].s, 0, y*100); //draws numbers
                   for(int x=0;x<balls[y].length;x++){ //draws all possible balls
                        g.drawString(balls[y][x].toString(), (x+1)*100, y*100); //draws letters
              do {
                   frame.repaint(); //repaints the balls when one is called
                   int x, y; //sets variables x and y as integers
                   boolean exit; //sets a boolean to the exit variable
                   do {
                        exit = false; //exit is set to false
                        x = (int)(Math.random() * 5); //picks a random number between 0 and 4 and stores it as x
                        y = (int)(Math.random() * 15); //picks a random number between 0 and 14 stores it as y
                        if (!balls[x][y].called) { //checks to see if a value is called
                             exit = true; //changes exit to true if it wasn't called
                             balls[x][y].called = true; //sets called in the Ball class to true if it wasn't called
                             System.out.println(balls[x][y]); //prints value
                   } while (!exit); //if exit is false, returns to top of loop
                   int count = 0; //sets a count for the number of balls called
                   for(int z=0;z<balls.length;z++){ //looks at balls
                        g.setColor(Color.black); //displays in black
                        g.drawString(balls[z][0].s, 0, z*100); //draws balls as a string
                        for(int a=0;a<balls[z].length;a++){ //looks at all balls
                             if (balls[z][a].called){ //if a ball is called
                                  g.setColor(Color.red); //change color to red
                                  count++; //increments count
                             } else {
                                  g.setColor(Color.black); //if it isn't called stay black
                             g.drawString(balls[z][a].toString(), (a+1)*100, y*100); //draws balls as string
                   do {
                        if (key.keyPressed == KeyEvent.VK_R||count==5*15) { //if R is pressed or count = 5*15
                             count=5*15; //changes count to 5*15
                             for(int z=0;z<balls.length;z++){ //recreates rows
                                  g.setColor(Color.black); //sets color to black
                                  g.drawString(balls[z][0].s, 0, z*100); //redraws rows
                                  for(int a=0;a<balls[z].length;a++){ //recreates columns
                                       balls[z][a] = new Ball(z, a+1); //fills array
                                       g.drawString(balls[z][a].toString(), (a+1)*100, z*100); //redraws columns
                   } while (key.keyPressed!=KeyEvent.VK_ENTER || count == 5 * 15); //determines if the key was pressed or counter is 5*15s
              } while (key.keyPressed == KeyEvent.VK_ENTER);
    public class Ball {
         String s; //initiates s that can store data type String
         int i; //initiates i that can store data as type integer
         boolean called = false; //initiates called as a boolean value and sets it to false
         public Ball(int x, int y) {
              i = (x * 15) + y; //stores number as i to be passed to be printed
              switch (x) { //based on x value chooses letter
              case 0:
                   s = "B";
                   break;
              case 1:
                   s = "I";
                   break;
              case 2:
                   s = "N";
                   break;
              case 3:
                   s = "G";
                   break;
              case 4:
                   s = "O";
         public String toString() { //overrides toString method, converts answer to String
              return s + " " + i; //returns to class bingo s and i
    }

    The javadoc of createImage() states that "The return value may be null if the component is not displayable."
    Not sure, but it may be that you need to call init() after this.setVisible(true).

  • Why do i get a null pointer exception

    import javax.swing.*;
    class Rental
         public static void main (String [] args)
            int custCounter = 0;                              // counts the customers created so far
                Customer[] customers = new Customer[100];          // creates an array of 100 customers
            DomesticAssistant[] assistants = new DomesticAssistant[3];          // creates an array of [3] domestic assistants
            assistants[0] = new DomesticAssistant("Lazy", 20, 100, 90, 300);     // creates the domestic assistant and stores it in the array at position [0]
            assistants[0].setReservedFrom(0, 0, 0);          // sets the reserved from date to zero
            assistants[0].setReservedTo(0, 0, 0);          // sets the reserved to date to zero
            assistants[1] = new DomesticAssistant("Average", 30, 150, 135, 400);     // creates the domestic assistant and stores it in the array at position [1]
            assistants[1].setReservedFrom(0, 0, 0);          // sets the reserved from date to zero
            assistants[1].setReservedTo(0, 0, 0);          // sets the reserved to date to zero
            assistants[2] = new DomesticAssistant("Excellent", 50, 250, 220, 750);     // creates the domestic assistant and stores it in the array at position [2]
            assistants[2].setReservedFrom(0, 0, 0);          // sets the reserved from date to zero
            assistants[2].setReservedTo(0, 0, 0);          // sets the reserved to date to zero
              String firstChoice = JOptionPane.showInputDialog("MAIN MENU\n--------------------\n\nPlease enter a number based on the following: \n[1] Add New Customer\n[2] Login\n[3] Exit");     // the main menu
            if(firstChoice.equals("1"))          // if the user enteres "1" in the main menu (add a new customer)
                String custName = JOptionPane.showInputDialog(null, "NEW CUSTOMER MENU\n--------------------\n\nName: ");     // asks for name and stores in variable custName
                   String custAddress = JOptionPane.showInputDialog(null, "NEW CUSTOMER MENU\n--------------------\n\nAddress: ");     // asks for sddress and stores in variable custAddress
                String custPostCode = JOptionPane.showInputDialog(null, "NEW CUSTOMER MENU\n--------------------\n\nPost Code: ");          // asks for post code and stores in variable custPostCode
                String custPhoneNo = JOptionPane.showInputDialog(null, "NEW CUSTOMER MENU\n--------------------\n\nTelephone Number: ");     // asks for phone number and stores in variable custPhoneNo
                String custEmail = JOptionPane.showInputDialog(null, "NEW CUSTOMER MENU\n--------------------\n\nEmail: ");          // asks for email and stores in variable custEmail
                String startingBalance = JOptionPane.showInputDialog(null, "NEW CUSTOMER MENU\n--------------------\n\nStarting Credit: ");     // asks for credit to start account with and stores in variable startingBalance
                int sBalance = Integer.parseInt(startingBalance);          // converts startingBalance from a string into an integer
                customers[custCounter] = new Customer(custName, custAddress, custPostCode, custPhoneNo, custEmail, sBalance);     // creates a customer with the variables/details entered above
                JOptionPane.showMessageDialog(null, "NEW CUSTOMER MENU\n--------------------\n\nWelcome" + custName + ".\nYour details were sucessfully added to the system.\nYour ID number is: " + customers[custCounter].getIdNumber() + "\nYour password is: " + customers[custCounter].getPassword());     // greets the new customer as well as giving them their id number and password
                custCounter++;          // increments the customer sounter by 1
            else if(firstChoice.equals("2"))          // if the user enters "2" in the main menu (login)
                String checkIdNo = JOptionPane.showInputDialog(null, "LOGIN\n--------------------\n\nPlease enter your ID Number: ");
                int checkIdNum = Integer.parseInt(checkIdNo);// asks user to enter their id number
                int position = 0;          //variable to store where we are in the array of customers so we know which customer we are dealing with
                for(int i = 0; i < customers.length; i++)          // loops through the array of customers
    ----->      if(customers.getIdNumber() == checkIdNum)          // when the id number entered is found
                             position = i;                              // set the position variable to that customer (the position in the customers array)
    else                                             // if the id number is not found
    JOptionPane.showMessageDialog(null, "LOGIN\n--------------------\n\nThat ID Number does not exist. ");     // tell the user that the id number wasnt found
    System.exit(0);                                                                           // then exit the system
    [\code]
    Can anyone help. when i run the program i get a null pointer exception
    can you tell me why, and possibly tell me how i can search through the array of customers searching for an id number
    am i doing it a way that will work (not the best way) but just so it works
    thanks in advance
    D_H

    Nevertheless, when you get to the loop where your exception occurs, you may have created any number of customers, but probably not 100.
    The loop tries to go through all 100 spaces in the array, and as soon as it gets to a space you haven't assigned a Customer too, you'll get the exception.
    Either make sure the loop doesn't go higher than you cutomercounter - 1 (to compensate for 0-based index of array), or check if the customer[i] == null before you try to call a method on it.
    Does that make sense?
    /D

  • Why am I receiving Null pointer Exception Error.

    why am I receiving Null pointer Exception Error.
    Hi I am developing a code for login screen. There is no syntex error as such ut I am receving the aove mentioned error. Can some one please help me ??
    ------------ Main.java------------------
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    public class Main implements ActionListener
    Frame mainf;
    MenuBar mb;
    MenuItem List,admitform,inquiry,exit,helpn;
    Menu newm,update,help;
    Inquiry iq;
    Admit ad;
    // HosHelp hp;
    Howuse hu;
    Register reg;
    Main()
    mainf=new Frame(" Engg College V/S Mumbai University ");
         mb=new MenuBar();
         newm=new Menu(" New ");
         update=new Menu(" Update ");
         help=new Menu(" Help ");
         List=new MenuItem("List");
         admitform=new MenuItem("Admit");
         inquiry=new MenuItem("Inquiry");
         exit=new MenuItem("Exit");
         helpn=new MenuItem("How to Use?");
    newm.add(List);
                   newm.add(admitform);
    newm.add(inquiry);
                   newm.add(exit);
         help.add(helpn);
              mb.add(newm);
              mb.add(update);
              mb.add(help);
    mainf.setMenuBar(mb);
                   exit.addActionListener(this);
                   List.addActionListener(this);
         inquiry.addActionListener(this);
         admitform.addActionListener(this);
    helpn.addActionListener(this);
         mainf.setSize(400,300);
         mainf.setVisible(true);
    public void actionPerformed(ActionEvent ae)
    if (ae.getSource()==List)
              reg=new Register();
         if(ae.getSource()==inquiry)
         iq=new Inquiry();
    if(ae.getSource()==admitform)
         ad=new Admit();
              if(ae.getSource()==helpn)
              hu=new Howuse();
              if(ae.getSource()==exit)
         mainf.setVisible(false);
    public static void main(String args[])
              new Main();
    -------------Register.java---------------------------
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    public class Register implements ActionListener//,ItemListener
    Label id,name,login,pass,repass;
    Button ok,newu,cancel,check;
    Button vok,iok,lok,mok,sok; //buttons for dialog boxes
    TextField idf,namef,loginf,passf,repassf;
    Dialog valid,invlog,less,mismat,acucreat;
    Frame regis;
    Checkbox admin,limit;
    CheckboxGroup type;
    DBconnect db;
    Register()
         db=new DBconnect();
    regis=new Frame("Registeration Form");
              type=new CheckboxGroup();
              admin=new Checkbox("Administrator",type,true);
              limit=new Checkbox("Limited",type,false);
              id=new Label("ID :");
    name=new Label("Name :");
         login=new Label("Login :");
         pass=new Label("Password :");
         repass=new Label("Retype :");
    idf =new TextField(20); idf.setEnabled(false);
         namef=new TextField(30); namef.setEnabled(false);
    loginf=new TextField(30); loginf.setEnabled(false);
         passf=new TextField(30); passf.setEnabled(false);
         repassf=new TextField(30); repassf.setEnabled(false);
    ok=new Button("OK"); ok.setEnabled(false);
         newu=new Button("NEW");
    cancel=new Button("Cancel");
         check=new Button("Check Login"); check.setEnabled(false);
    vok=new Button("OK");
         iok=new Button("OK");
              lok=new Button("OK");
              mok=new Button("OK");
              sok=new Button("OK");
    valid=new Dialog(regis,"Login name is valid !");
         invlog=new Dialog(regis,"Login name already exist!");
         less=new Dialog(regis,"Password is less than six characters !");
    mismat=new Dialog(regis,"password & retyped are not matching !");
    acucreat=new Dialog(regis,"You have registered successfully !");
         regis.setLayout(null);
    //     regis.setBackground(Color.orange);
    valid.setLayout(new FlowLayout());
         invlog.setLayout(new FlowLayout());
         less.setLayout(new FlowLayout());
         mismat.setLayout(new FlowLayout());
    acucreat.setLayout(new FlowLayout());
    id.setBounds(35,50,80,25); //(left,top,width,hight)
    idf.setBounds(125,50,40,25);
    name.setBounds(35,85,70,25);
    namef.setBounds(125,85,150,25);
    login.setBounds(35,120,80,25);
    loginf.setBounds(125,120,80,25);
    check.setBounds(215,120,85,25);
         pass.setBounds(35,155,80,25);
    passf.setBounds(125,155,80,25);
    repass.setBounds(35,190,80,25);
    repassf.setBounds(125,190,80,25);
    admin.setBounds(35,225,100,25);
    limit.setBounds(145,225,100,25);
              ok.setBounds(45,265,70,25);
         newu.setBounds(135,265,70,25);
    cancel.setBounds(225,265,70,25);
         passf.setEchoChar('*');
    repassf.setEchoChar('*');
         regis.add(id);
         regis.add(idf);
    regis.add(name);
         regis.add(namef);
         regis.add(login);
         regis.add(loginf);
         regis.add(check);
    regis.add(pass);
         regis.add(passf);
    regis.add(repass);
         regis.add(repassf);
         regis.add(ok);
         regis.add(newu);
         regis.add(cancel);
    regis.add(admin);
         regis.add(limit);
    valid.add(vok);
         invlog.add(iok);     
         less.add(lok);
         mismat.add(mok);
    acucreat.add(sok);
    ok.addActionListener(this);
         newu.addActionListener(this);
    check.addActionListener(this);
    cancel.addActionListener(this);
         // limit.addItemListener(this);
         //admin.addItemListener(this);
              vok.addActionListener(this);
              iok.addActionListener(this);
         lok.addActionListener(this);
         mok.addActionListener(this);
         sok.addActionListener(this);
    regis.setLocation(250,150);
    regis.setSize(310,300);
    regis.setVisible(true);
         public void actionPerformed(ActionEvent ae)
         if(ae.getSource()==check)
              try{
                   String s2=loginf.getText();
    ResultSet rs=db.s.executeQuery("select* from List");
                        while(rs.next())
                   if(s2.equals(rs.getString(2).trim()))
    //                    invlog.setBackground(Color.orange);
                             invlog.setLocation(250,150);
                             invlog.setSize(300,100);
                   cancel.setEnabled(false);
    ok.setEnabled(false);
    check.setEnabled(false);
                        invlog.setVisible(true);
                             break;
                        else
                        //     valid.setBackground(Color.orange);
                             valid.setLocation(250,150);
                             valid.setSize(300,100);
                   cancel.setEnabled(false);
    ok.setEnabled(false);
    check.setEnabled(false);
                   valid.setVisible(true);
                        }catch(Exception e)
                   e.printStackTrace();
    if(ae.getSource()==newu)
         try{
              ResultSet rs=db.s.executeQuery("select max(ID) from List");
         while(rs.next())
    String s1=rs.getString(1).trim();
                   int i=Integer.parseInt(s1);
    i++;
                   String s2=""+i;
    idf.setText(s2);
                   newu.setEnabled(false);
                   namef.setText(""); namef.setEnabled(true);
              loginf.setText(""); loginf.setEnabled(true);
              passf.setText(""); passf.setEnabled(true);
              repassf.setText(""); repassf.setEnabled(true);
              ok.setEnabled(true);
                   check.setEnabled(true);
                   }catch(Exception e)
              e.printStackTrace();
         if(ae.getSource()==ok)
              try
              String s1=idf.getText();
              String s2=loginf.getText();
              String s3=passf.getText();
         String s4=repassf.getText();
         int x=Integer.parseInt(s1);
         int t;
         if(type.getSelectedCheckbox()==admin)
              t=1;
              else
              t=0;
    ResultSet rs=db.s1.executeQuery("select* from List");
                   while(rs.next())
                   if(s2.equals(rs.getString(2).trim()))
                        invlog.setBackground(Color.orange);
                        invlog.setLocation(250,150);
                        invlog.setSize(300,100);
                   cancel.setEnabled(false);
    ok.setEnabled(false);
    check.setEnabled(false);
                        invlog.setVisible(true);
                        break;
                   else
                        if (s3.length()<6)
                        less.setBackground(Color.orange);
                             less.setLocation(250,150);
                             less.setSize(300,100);
                   ok.setEnabled(false);
                        cancel.setEnabled(false);
                        check.setEnabled(false);
                        less.setVisible(true);
    else if(!(s3.equals(s4)))
                        mismat.setBackground(Color.orange);
                        mismat.setLocation(250,150);
                        mismat.setSize(300,100);
                        ok.setEnabled(false);
                        cancel.setEnabled(false);
                        check.setEnabled(false);
                        mismat.setVisible(true);
                        else
    db.s1.execute("insert into User values("+x+",'"+s2+"','"+s3+"',"+t+")");
                        acucreat.setBackground(Color.orange);
                        acucreat.setLocation(250,150);
                        acucreat.setSize(300,100);
                        regis.setVisible(false);
                        acucreat.setVisible(true);
                   }//else
              }//while
                   } //try
              catch(Exception e1)
              // e1.printStackTrace();
              if (ae.getSource()==cancel)
              regis.setVisible(false);
              if (ae.getSource()==vok)
              ok.setEnabled(true);
                   cancel.setEnabled(true);
    check.setEnabled(true);
                   valid.setVisible(false);
              if (ae.getSource()==iok)
              ok.setEnabled(true);
                   cancel.setEnabled(true);
    check.setEnabled(true);
                   invlog.setVisible(false);
              if (ae.getSource()==lok)
              less.setVisible(false);
                   cancel.setEnabled(true);
    ok.setEnabled(true);
    check.setEnabled(true);
              if (ae.getSource()==mok)
              mismat.setVisible(false);
                   cancel.setEnabled(true);
    ok.setEnabled(true);
    check.setEnabled(true);
    if (ae.getSource()==sok)
              acucreat.setVisible(false);
              ok.setEnabled(false);
                   newu.setEnabled(true);
                   regis.setVisible(true);
         public static void main(String args[])
         new Register();
    -----------DBConnect.java------------------------------------
    import java.sql.*;
    public class DBconnect
    Statement s,s1;
    Connection c;
    public DBconnect()
    try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              c=DriverManager.getConnection("jdbc:odbc:Sonal");
              s=c.createStatement();
    s1=c.createStatement();
         catch(Exception e)
         e.printStackTrace();
    ----------Login.java----------------
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    public class Login implements ActionListener
    Frame log;
    Label login,pass;
    TextField loginf,passf;
    Button ok,cancel;
    Dialog invalid;
    Button iok;
    Register reg;
    DBconnect db;
    Main m;
    Login()
    db=new DBconnect();
         log=new Frame();
         log.setLocation(250,210);
         login=new Label("Login :");
    pass=new Label("Password :");
         loginf=new TextField(20);
         passf=new TextField(20);
         passf.setEchoChar('*');
         ok=new Button("OK");
         // newu=new Button("New User");
         cancel=new Button("CANCEL");
         iok=new Button(" OK ");
    invalid=new Dialog(log,"Invalid User!");
    //log.setBackground(Color.cyan);
    //log.setForeground(Color.black);
         log.setLayout(null);
         // iok.setBackground(Color.gray);
         invalid.setLayout(new FlowLayout());
         login.setBounds(35,50,70,25); //(left,top,width,hight)
         loginf.setBounds(105,50,100,25);
         pass.setBounds(35,85,70,25);
         passf.setBounds(105,85,70,25);
         ok.setBounds(55,130,70,25);
    // newu.setBounds(85,120,80,25);
    cancel.setBounds(145,130,70,25);
    log.add(login);
    log.add(loginf);
    log.add(pass);
    log.add(passf);
    log.add(ok);
    // log.add(newu);
    log.add(cancel);
         invalid.add(iok);//,BorderLayout.CENTER);
    ok.addActionListener(this);
    // newu.addActionListener(this);
    cancel.addActionListener(this);
         iok.addActionListener(this);
    log.setSize(300,170);
    log.setVisible(true);
    public void actionPerformed(ActionEvent a)
    if(a.getSource()==ok)
         try{
              String l=loginf.getText();
              String p=passf.getText();
              ResultSet rs=db.s.executeQuery("select * from List");
              while(rs.next())
              if(l.equals(rs.getString(2).trim())&& p.equals(rs.getString(3).trim()))
                        String tp=rs.getString(4).trim();
                             int tp1=Integer.parseInt(tp);
    log.setVisible(false);
    if(tp1==1)
                             m=new Main();
                        // m.List.setEnabled(true);
                             else
                             m=new Main();
                             m.List.setEnabled(false);
                        break;
    else
                   invalid.setBackground(Color.orange);
                   invalid.setSize(300,100);
                   invalid.setLocation(250,210);
                   cancel.setEnabled(false);
              ok.setEnabled(false);
                   invalid.setVisible(true);
                   }catch(Exception e1)
                   e1.printStackTrace();
         if (a.getSource()==cancel)
         log.setVisible(false);
         if (a.getSource()==iok)
         invalid.setVisible(false);
         loginf.setText("");
         passf.setText("");
         cancel.setEnabled(true);
    ok.setEnabled(true);
         public static void main(String[] args)
         new Login();
    -------------inquiry.java---------------------------------
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.Date;
    import java.text.*;
    import java.sql.*;
    public class Inquiry implements ActionListener
    Frame inqry;
    Label name,addr;
    TextField namef,addrf;
    Button ok,cancel,dok;
    Dialog invalid;
    Frame result; //Result of the inquiry....
    Label lrname,lraddr,lward,lrdate,lcdate;
    TextField rname,raddr,ward,rdate,cdate;
    Date d;
    DateFormat df;
    Button rok,rcancel;
    Dialog success;
    Button rdok;
    DBconnect db;
    Inquiry()
              db=new DBconnect();
              inqry=new Frame("Inquiry Form");
              inqry.setLayout(null);
    inqry.setBackground(Color.cyan);
              name=new Label(" NAME ");
              addr=new Label("ADDRESS");
              namef=new TextField(20);
              addrf=new TextField(20);
              ok=new Button("OK");
              cancel=new Button("CANCEL");
              dok=new Button("OK");
              invalid=new Dialog(inqry,"Invalid Name or Address !");
              invalid.setSize(300,100);
         invalid.setLocation(300,180);
              invalid.setBackground(Color.orange);
              invalid.setLayout(new FlowLayout());
    result=new Frame(" INQUIRY RESULT "); //Result Window......
    result.setLayout(null);
    result.setBackground(Color.cyan);
    lcdate=new Label(" DATE ");
         lrname=new Label(" NAME ");
    lraddr=new Label(" ADDRESS ");
         lward=new Label(" WARD ");
         lrdate=new Label(" ADMIT-DATE ");
    cdate=new TextField(10);
         rname=new TextField(20);
    rname.setEnabled(false);
         raddr=new TextField(20);
         raddr.setEnabled(false);
         ward=new TextField(20);
         ward.setEnabled(false);
         rdate=new TextField(10);
         rdate.setEnabled(false);
         cdate=new TextField(20);
         d=new Date();
         df=DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.KOREA);
         cdate.setText(df.format(d));
         cdate.setEnabled(false);
    rok=new Button(" OK ");
         rcancel=new Button("CANCEL");
              name.setBounds(40,50,50,25);
    namef.setBounds(120,50,130,25);
    addr.setBounds(40,100,60,25);
    addrf.setBounds(120,100,80,25);
    ok.setBounds(60,145,70,25);
              cancel.setBounds(140,145,70,25);
              lcdate.setBounds(200,50,60,25); //Result Window......
    cdate.setBounds(270,50,80,25);      
    lrname.setBounds(35,85,70,25);
    rname.setBounds(140,85,180,25);
    lraddr.setBounds(35,120,80,25);
         raddr.setBounds(140,120,100,25);
    lward.setBounds(35,155,80,25);
    ward.setBounds(140,155,100,25);
    lrdate.setBounds(30,190,80,25);
    rdate.setBounds(140,190,80,25);
    rok.setBounds(70,240,70,25);
    rcancel.setBounds(170,240,70,25);
              inqry.add(name);
              inqry.add(namef);
              inqry.add(addr);
              inqry.add(addrf);
              inqry.add(ok);
              inqry.add(cancel);
    invalid.add(dok);
         result.add(lcdate); //Result Window......
         result.add(cdate);
              result.add(lrname);
              result.add(rname);
              result.add(lraddr);
              result.add(raddr);
              result.add(lward);
              result.add(ward);
              result.add(lrdate);
              result.add(rdate);
              result.add(rok);
              result.add(rcancel);
         ok.addActionListener(this);
         cancel.addActionListener(this);
         dok.addActionListener(this);
    rok.addActionListener(this); //Result Window......
         rcancel.addActionListener(this);
         inqry.setSize(280,180);
         inqry.setLocation(300,180);
         inqry.setVisible(true);
              result.setSize(400,280); //Result Window......
         result.setLocation(200,150);
         result.setVisible(false);
              public void actionPerformed(ActionEvent ae)
                   if(ae.getSource()==ok)
                   try
                             String nm=namef.getText();
                             String ad=addrf.getText();
                             inqry.setVisible(false);
                             ResultSet rs=db.s.executeQuery("select * from Billinformation");
                             while(rs.next())
                                  String nm1=rs.getString(2).trim();
                                  String ad1=rs.getString(3).trim();
                                  int k=0;
                                  if((nm1.equals(nm))&&(ad1.equals(ad)))
                             String adm=rs.getString(5).trim();
                             String wr=rs.getString(6).trim();
                             String bd=rs.getString(8).trim();
                                  String wrb=wr+"-"+bd;
    result.setVisible(true);
                                  rname.setText(nm1);
                             raddr.setText(ad1);
                             ward.setText(wrb);
                             rdate.setText(adm);
    k=1;
                                  break;
                                  }//if
                             else if(k==1)
                             invalid.setVisible(true);
                             }//while
    }//try
                             catch(Exception e)
                             e.printStackTrace();
                        } //getsource ==ok
                   if(ae.getSource()==cancel)
    inqry.setVisible(false);
                        if(ae.getSource()==rok) //Result Window......
                        namef.setText("");
                             addrf.setText("");
                             result.setVisible(false);
                        inqry.setVisible(true);
    if(ae.getSource()==rcancel)
    result.setVisible(false);
                        if(ae.getSource()==dok)
                        namef.setText("");
                             addrf.setText("");
                             invalid.setVisible(false);
                             inqry.setVisible(true);
         public static void main(String args[])
              new Inquiry();
    PLease Help me !!
    I need this urgently.

    can you explain what your program tries to do... and
    at where it went wrong..Sir,
    We are trying to make an project where we can make a person register in our data base & after which he/she can search for other user.
    The logged in user can modify his/her own data but can view other ppl's data.
    We are in a phase of registering the user & that's where we are stuck. The problem is that after the login screen when we hit register (OK- button) the data are not getting entered in the data base.
    Can u please help me??
    I am using "jdk1.3' - studnet's edition.
    I am waiting for your reply.
    Thanks in advance & yr interest.

  • Null Pointer Exception in Message Area

    Hi!
    I just want to get some inputs. I have this Message Area to display errors in Web Dynpro, but from time to time I get this Null Pointer Exception when an event takes place. Don't know why this happens, but the trace is not found my code.
    Here's the Stack Trace:
    +"java.lang.NullPointerException+
    ++     at com.sap.tc.webdynpro.clientserver.uielib.pattern.uradapter.MessageAreaAdapter._getConnectedControlId(MessageAreaAdapter.java:3684)++
    ++     at com.sap.tc.webdynpro.clientserver.uielib.pattern.uradapter.MessageAreaAdapter.access$900(MessageAreaAdapter.java:67)++
    ++     at com.sap.tc.webdynpro.clientserver.uielib.pattern.uradapter.MessageAreaAdapter$Rows.doNext(MessageAreaAdapter.java:2188)++
    ++     at com.sap.tc.webdynpro.clientserver.uielements.adaptbase.IndexedItemsIterator.next(IndexedItemsIterator.java:54)++
    ++     at com.sap.tc.webdynpro.clientserver.uielib.pattern.uradapter.MessageAreaAdapter.getSelection(MessageAreaAdapter.java:3653)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:424)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)++
    ++     at com.sap.tc.ur.renderer.ie6.SingleColumnLayoutRenderer.renderSingleColumnLayoutCellFragment(SingleColumnLayoutRenderer.java:679)++
    ++     at com.sap.tc.ur.renderer.ie6.SingleColumnLayoutRenderer.renderSingleColumnLayoutFragment(SingleColumnLayoutRenderer.java:253)++
    ++     at com.sap.tc.ur.renderer.ie6.SingleColumnLayoutRenderer.render(SingleColumnLayoutRenderer.java:74)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)++
    ++     at com.sap.tc.ur.renderer.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:619)++
    ++     at com.sap.tc.ur.renderer.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:74)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)++
    ++     at com.sap.tc.ur.renderer.ie6.TabStripRenderer.renderTabStripItemContentFragment(TabStripRenderer.java:1799)++
    ++     at com.sap.tc.ur.renderer.ie6.TabStripRenderer.renderTabStripFragment(TabStripRenderer.java:879)++
    ++     at com.sap.tc.ur.renderer.ie6.TabStripRenderer.render(TabStripRenderer.java:69)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)++
    ++     at com.sap.tc.ur.renderer.ie6.MatrixLayoutRenderer.renderMatrixLayoutCellFragment(MatrixLayoutRenderer.java:790)++
    ++     at com.sap.tc.ur.renderer.ie6.MatrixLayoutRenderer.renderMatrixLayoutRowFragment(MatrixLayoutRenderer.java:376)++
    ++     at com.sap.tc.ur.renderer.ie6.MatrixLayoutRenderer.renderMatrixLayoutFragment(MatrixLayoutRenderer.java:326)++
    ++     at com.sap.tc.ur.renderer.ie6.MatrixLayoutRenderer.render(MatrixLayoutRenderer.java:79)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)++
    ++     at com.sap.tc.ur.renderer.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:619)++
    ++     at com.sap.tc.ur.renderer.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:74)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.UiWindowRenderer.render(UiWindowRenderer.java:52)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendHtml(HtmlClient.java:1058)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.fillDynamicTemplateContext(HtmlClient.java:458)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendResponse(HtmlClient.java:1245)++
    ++     at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.retrieveData(HtmlClient.java:253)++
    ++     at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doRetrieveData(WindowPhaseModel.java:595)++
    ++     at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:156)++
    ++     at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)++
    ++     at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)++
    ++     at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:321)++
    ++     at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:713)++
    ++     at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:666)++
    ++     at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)++
    ++     at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)++
    ++     at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)++
    ++     at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)++
    ++     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)++
    ++     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)++
    ++     at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)++
    ++     at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)++
    ++     at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)++
    ++     at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)++
    ++     at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)++
    ++     at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)++
    ++     at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)++
    ++     at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)++
    ++     at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)++
    ++     at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)++
    ++     at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)++
    ++     at java.security.AccessController.doPrivileged(Native Method)++
    ++     at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102)++
    ++     at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)"++
    Just wondering if this can be solved on my end or is this a glitch? Would really appreciate some inputs!
    Thanks!

    Hi,
    Here two possibility
    1. This  is the case when we get something as return form the BAPI/RFC and want to display in our message area but return message itself is null like this statement
    wdComponentAPI.getMessageManager().reportException(wdContext.nodeOutput_Salesorder_Create().currentOutput_Salesorder_CreateElement().getSalesdocument());
    2.And this is when
      try
                   executableClazz.execute();
                   nodeToinvalidate.invalidate();
              } catch (WDDynamicRFCExecuteException ree)
                   wdComponentAPI.getMessageManager().reportException(ree);
                             or
    wdComponentAPI.getMessageManager().reportException(ree.getMessage);
    3. Message Area is simple UI element which ensure only the place where we have to so the message
    So Check your code again it might solve your problem
    Best Regards
    Satish Kumar

  • Really frustrating Null Pointer Exception

    Hi I had the day off and was bored so I decided to start work on a poker game. Today I just started making a deck of cards and drawing a random card from it. However it isn't working as I get a very annoying null pointer exception which I don't understand. Anyway I will post my code:
    public class DeckOfCards
         public static void main(String args[])
              Deck daDeck = new Deck();
              Card[] drawnCards = new Card[10];
              for (int i=0; i < 10; ++i)
                   drawnCards[i] = daDeck.DrawCard();
                   System.out.println(drawnCards.getTitle());
    import java.util.*;
    public class Deck
         Suit Hearts;
         Suit Diamonds;
         Suit Spades;
         Suit Clubs;
         public void Deck()
              Hearts = new Suit("Hearts");
              Diamonds = new Suit("Diamonds");
              Spades = new Suit("Spades");
              Clubs = new Suit("Clubs");
         public Card DrawCard()
              System.out.println("Drawing card...");
              Random generator = new Random();
              Card card = null;
              System.out.println("Card variable inited");
              while (card == null)
                   System.out.println("Bleep");
                   switch (generator.nextInt(4))
                        case 0:
                             System.out.println("0");
                             return Hearts.getAvailableCard();
                        case 1:
                             System.out.println("1");
                             return Diamonds.getAvailableCard();
                        case 2:
                             System.out.println("2");
                             return Spades.getAvailableCard();
                        case 3:
                             System.out.println("3");
                             return Clubs.getAvailableCard();
                        default:
                             System.out.println("none");                    
              System.out.println("Exited while loop");
              return card;
    import java.util.*;
    public class Suit
         Card[] cards = new Card[13];
         public Suit(String suit_)
              cards[0] = new Card("Two", suit_);
              cards[1] = new Card("Three", suit_);
              cards[2] = new Card("Four", suit_);
              cards[3] = new Card("Five", suit_);
              cards[4] = new Card("Six", suit_);
              cards[5] = new Card("Seven", suit_);
              cards[6] = new Card("Eight", suit_);
              cards[7] = new Card("Nine", suit_);
              cards[8] = new Card("Ten", suit_);
              cards[9] = new Card("Jack", suit_);
              cards[10] = new Card("Queen", suit_);
              cards[11] = new Card("King", suit_);
              cards[12] = new Card("Ace", suit_);
         public Card getAvailableCard()
              System.out.println("Getting an available card...");
              Random generator = new Random();
              Card card = new Card();
              int randomNo = generator.nextInt(13);
              System.out.println(randomNo);
              if (cards[randomNo].isAvailable())
                   return cards[randomNo];
              return card;
    public class Card
         String strValue;
         String suitName;
         int value;
         int suit;
         boolean available = true;
         public Card()
              strValue = "Out";
              suitName = "cards";
         public Card(String strValue_, String suitName_)
              strValue = strValue_;
              suitName = suitName_;
         public String getTitle()
              String title = strValue + " of " + suitName;
              return title;
         public void setAvailable(boolean available_)
              available = available_;
         public boolean isAvailable()
              return available;
    What the program is meant to do is create a deck of cards, then pick ten cards, randomly picking a suit and card in that suit. If the card has already been drawn ( not available ) then the DrawCard() method should repick a suit and card and try again. The program may be doing something differently to what I have said and may be a bit messy just because I have messed around with things trying to understand why I am getting the exception. This is the exception:
    Exception in thread "main" java.lang.NullPointerException
    at Deck.DrawCard(Deck.java:34)
    at DeckOfCards.main(DeckOfCards.java:13)
    The program doesn't even make it to the first line of the getAvailableCard() method in the Suit Class.
    So all I am asking is can anyone see why I am getting the null pointer exception and what action could I take to fix it. Thankyou to anyone who has read this.

    Figure out what's null.
    Print out cards and then cards[randomNo].
    If those aren't null, then you need to look more closely at the erorr message and put in print statements to find out what is.
    Whatever turns out to be null, you'll need to trace back and figure out why.
    If it's the array, and the array is a member variable, then you need to know that reference member variables are initilaized to null.
    If the array isn't null (because you did cards = new Card[something]) but cards[randomNo] is null, then it's because you didn't do this: for (int ix = 0; ix < cards.length; ix++) {
        cards[ix] = new Card(...);
    }

  • Mediatracker (waitforid) - null pointer exception

    Ok in the run event..
             try {
              if(CURLOAD<=47) {
              try {
              im[CURLOAD] = getImage(new URL(URLtoUse, LNKS[CURLOAD]));
              } catch(MalformedURLException e) {
                   System.out.println("Error loading images.");
                   s="Error loading images.";
              System.out.println("Curload: "+String.valueOf(CURLOAD));
              tracker.addImage(im[CURLOAD], CURLOAD);
              tracker.waitForID(CURLOAD);
              CURLOAD++;
              //tracker.waitForID(1);
             } catch (InterruptedException e) {
              return;
             }CURLOAD will be 0-47, but on 0 it it gives a null pointer exception on the line "tracker.waitForID(CURLOAD);" anyone know why? I thought I would assign a new mediatracker id for every image loaded.. but it doesn't feel like working :(

    tracker is my mediatracker, and waitForID is a built-in java function.. it waits until the image is done loading (or is supposed to)
    Edit: Solved by myself... forgot to set LNKS array
    Edited by: Dazappa on Apr 7, 2008 9:24 PM

  • JFrame will not close giving null pointer exception

    Hello ev1, Heres what I'm doing, I have a menu with JButtons that when pressed will take you to a game (this works fine). When your done with the game, you press a button that closes the JFrame(game) and starts the menu again (this gives the error null pointer exception). Heres a brief summary of the design:
    FullScreenSetup class
    has openWindow() that sets up a new full screen JFrame. (works)
    has closeWindow() that removes everything in the contentPane and sets
    visible(false).
    GameMenu class
    uses FullScreenSetup via FullScreenSetup window;
    uses window.openWindow() to set up the window.
    also sets up the buttons and handles them when pressed
    VideoPoker class (the game)
    uses FullScreenSetup via FullScreenSetup window;
    runs the game and has the button that should close the window and go
    back to the menu.
    heres how i thought it should work, in the actionPerformed method I have
    window.closeWindow(); <- this gives me the error
    new GameMenu(); <- this is my ultimate goal (hopefully brings me
    back to the menu screen to choose another game)
    I hope what I have written is enough for someone to help me because I know what it is like to read through hundreds of lines of code to help someone. Thx.

    What I cannot understand is that when going from the menu to the game I use window.closeWindow(); so that I can clear the menu and paste the game on the screen this works fine. so why does it not work a second time?

  • Null pointer exception using ImageIO

    Hi all I'm not sure this belongs here or in the applet forum, but if don't belong here I'll move it. Anyway My question is this, I am trying to load an image into an applet before I was just doing this
    public static Image getImage(String filename){
              if (applet == null)
                  return null; // for now
             else
                  return applet.getImage(applet.getDocumentBase(), filename);
         }Since then I've discovered ImageIO and have switched to this
    public static BufferedImage getImage(String filename){
              BufferedImage img = null;
              //File image = new File(filename);
              try{
                   //img = ImageIO.read(applet.getDocumentBase().getClass().getResource(filename));
                   //img = ImageIO.read(image);
                   img = ImageIO.read(ImageHandler.getFile(filename));
              }catch(IOException e){
                   e.printStackTrace();
                   return null;
              return img;Now my problem is that this is giving me a null pointer exception, each of the 3 times I try to load up the img variable I get a NPE and I cannot figure out why. I know the file is where its supposed to be and I know it is not corrupt since it works with the other code. So my question is why am I getting an exception with the second piece of code? Any advice or suggestions are appreciated thanks in advance.

    Well that was part of the problem, thanks for that I didn't catch that at first, but now it just created a new exception in that I'm getting a illegal argument exception saying that the input == null. Here is the entire class I should have posted it in the first place sorry
    import java.applet.Applet;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    public class ImageHandler {
         static Applet applet = null;
         public static void setApplet(Applet applet){
              ImageHandler.applet = applet;
         public static BufferedImage getImage(String filename){
              BufferedImage img = null;
              if(applet == null){
                   System.out.println("Applet is null");//for testing
                   return null; //for now
              }else{
                   try{
                        img = ImageIO.read(applet.getDocumentBase().getClass().getResource(filename));
                   }catch(IOException e){
                        e.printStackTrace();
                        return null;
                   return img;
    }The applet gets set in another class here:
    ImageHandler.setApplet(this);so unless I'm missing something (obviously I am or I won't be here lol) the applet is not null here is the errors I get again thanks for the help you've already given anymore is appreciated.
    java.lang.IllegalArgumentException: input == null!
         at javax.imageio.ImageIO.read(Unknown Source)
         at ImageHandler.getImage(ImageHandler.java:27)
         at BackgroundImages.<init>(BackgroundImages.java:17)
         at BackGrounds.<init>(BackGrounds.java:17)
         at MainGame.init(MainGame.java:51)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)

  • Null pointer exception and servlet

    I cant figure out why i am getting a null pointer exception. this works if i keep my form output in the same class as my driving servlet. All i did was break off the html display to a new form and i get a null pointer exception.
    this is just an excerpt. no reason to post the whole form.
    Here are my two classes...
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.text.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;
    import org.w3c.dom.Element;
    public class myServlet extends HttpServlet
       implements SingleThreadModel {
            displayScreen myAddressBook;
            HttpServletRequest request;
            HttpServletResponse response;
            String displayForm = "DISPLAYFORM";
            String addForm     = "ADDFORM";
            String editForm    = "EDITFORM";
         // get function
        public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
              request = this.request;
              response = this.response;
            displayScreen myAddressBook = new displayScreen(this.request,this.response);
            myAddressBook.sendAddressBook(request,response,false,displayForm);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
         errorMsg = "";
         errCount=0;
         //stores address book in hashmap. Not currently using Address Book object
         request = this.request;
        response = this.response;
         if ((request.getParameterValues("submit")[0].equals("Next")))
            myAddressBook.sendAddressBook(request,response,false,displayForm);
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.text.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.*;
    public class displayScreen {
         int errCount;
         String errorMsg;
         String displayForm = "DISPLAYFORM";
         String addForm     = "ADDFORM";
         String editForm    = "EDITFORM";
         HttpServletRequest request;
         HttpServletResponse response;
           displayScreen (HttpServletRequest request, HttpServletResponse response) {
               request = this.request;
               response = this.response;
    public void sendAddressBook (HttpServletRequest request, HttpServletResponse response,boolean FileError,String formType)
             throws ServletException, IOException {
            request = this.request;
            response = this.response;
         response.setContentType("text/html");  /*****/ I GET A NULL POINTER EXCEPTION RIGHT HERE!!!!!!
    }

    anyway to write the system.err to an html screen with
    a servlet?Why would you ask that? Surely you should have asked "Any way to write a stack trace to an HTML screen from a servlet?"
    And in fact there is. I am sure you have not yet looked up the Exception class and the versions of its printStackTrace() method. But when you do, you will see that there are printStackTrace(PrintStream) and printStackTrace(PrintWriter). And you know how to write HTML (or text in general) to the servlet response so that it shows up in the client's browser, right? I will let you figure out how to put those things together.

  • Crystal report (crystalReportsViewer) crash with null pointer exception

    Hi,
    My application are simple : m_crystalReportsViewer.ViewerCore.ReportSource = report; but in throw exception null pointer when I call showDialog.
    I see in code, we have method ShowTabHeader.
    private void ShowTabHeader(bool isShow)
        Grid child = VisualTreeHelper.GetChild(this.tabViews, 0) as Grid;
        TabPanel panel = child.FindName("HeaderPanel") as TabPanel;
        if (!isShow)
            panel.Visibility = Visibility.Collapsed;
        else
            panel.Visibility = Visibility.Visible;
    My problem :  child.FindName("HeaderPanel") as TabPanel return null
    =>  if (!isShow)
            panel.Visibility = Visibility.Collapsed;
        else
            panel.Visibility = Visibility.Visible;
    throws null pointer exception.
    Do you have any idea about this?
    Thanks.
    Here is stack trace :
    Unerwarteter Fehler im System ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at SAPBusinessObjects.WPF.Viewer.ReportAlbum.ShowTabHeader(Boolean isShow)
       at SAPBusinessObjects.WPF.Viewer.ReportAlbum.ItemsChangedEventHandler(Object sender, ItemsChangedEventArgs e)
       at System.Windows.Controls.Primitives.ItemsChangedEventHandler.Invoke(Object sender, ItemsChangedEventArgs e)
       at System.Windows.Controls.ItemContainerGenerator.OnItemAdded(Object item, Int32 index)
       at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
       at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
       at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
       at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
       at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Add(T item)
       at SAPBusinessObjects.WPF.Viewer.ReportAlbum.OnCreateNewDocumentViewComplete(CreateNewDocumentArgs args)
       at SAPBusinessObjects.WPF.Viewer.DelegateMarshaler.<>c__DisplayClass6`1.<Invoke>b__4(Object )
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       --- End of inner exception stack trace ---
    Edited by: duyhai707 on Jul 13, 2011 7:42 PM
    Edited by: duyhai707 on Jul 13, 2011 8:09 PM

    A lot I don't understand in here... actually, I don't understand anything in your post:
    When you call ShowDialog, what exactly are you trying to show?  The code is the decompiled showtabheader method of the viewer. So, are you trying to override the viewer control and reportalbum?  My guess is that the null reference is for the reportalbum's child object which is not the reportalbum object of the viewer.  I don't understand why the code since its all handled internally to the viewer anyhow.
    Perhaps searching the forum for code sample will help?
    Also, see the [WPF Demo|http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/a09f7025-0629-2d10-d7ae-df006a51d1a8]
    Other good WPF resources to consult:
    http://www.redmondpie.com/incorporate-crystal-reports-in-a-c-wpf-application/
    http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/a09f7025-0629-2d10-d7ae-df006a51d1a8
    http://www.codeproject.com/Tips/74499/Crystal-Report-in-WPF.aspx
    Re: Crystal Reports for Visual Studio 2010 - WPF Viewer for .Net 4.0
    http://codegain.com/articles/crystalreports/howto/incorporate-crystal-reports-in-wpf-using-c-sharp.aspx
    CRVS2010 Beta - WPF Viewer, how to hide the GroupTree control?
    Re: CRVS2010 Beta - WPF Viewer, how to hide the GroupTree control?
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Null pointer exception while inserting a new row in ADF with jdev

    Hi,
    In ADF, I have retrieved some user information from LDAP server and I want to insert those values in to my table. But when I do this, I am getting a null pointer exception when I get the view object (ViewObject vo=getCRUIP002_1();). I am not sure why this happens.
    Here is my code. It is urgent.
    and please some one help me in fixing the issue.
    ViewObject vo=getCRUIP002_1();
    vo.clearCache();
    vo.setMaxFetchSize(0);
    vo.executeQuery();
    Row newRow=vo.createRow();
    vo.insertRow(newRow);
    SearchResult res = (SearchResult)results.next();
    Attributes attrs = res.getAttributes();
    // Row newRow = vo.getCurrentRow();
    newRow.setAttribute("LOGINNAME",(Object)attrs.get("sn").get().toString());
    newRow.setAttribute("PASSWORDVALUE","x");
    newRow.setAttribute("FIRSTNAME",(Object)attrs.get("sn").get().toString());
    newRow.setAttribute("LASTNAME",(Object)attrs.get("sn").get().toString());
    newRow.setAttribute("EMAIL",(Object)attrs.get("mail").get().toString());
    Thanks,
    Priya.S

    assuming ur jdev version is 10.1.2
    ViewObject vo=getCRUIP002_1();i dont think ur getting the view object hence null pointer expception.
    ViewObject vo = findViewObject("MyView1");
    if u r in the object class then first get the root application module and then access the View obejct from there.
    In ADF if u assign a null value, u will always get the null pointer exception coz of java. Run the app in debug mode and check the values step by step, by the way there is not exception handling in ur code either, Do u know how to debug in Jdev ?
    zaibi.

  • Java Null Pointer Exception- Business Validation In AM

    Hi, I have been tried cracking this validation issue, tried several combinations. But does not work and throw java null pointer exception. I would appreciate if somebody can point where I am going wrong on the code. Thanks ahead.
    Below is the issue:-
    I have a page with PO (blanket purchase order) header info, and a PO line info with additional empty columns (related to Blanket Release). When the user fills in one of the columns (release amount, rls_amt_i), then I need to validate this against remaining blanket amount ie.{ PO_amt - (po_rls_amt1 + po_rls_amt2+..)}. If rls_amt_i is <= remaining amount, then the release needs to get created, otherwise shouldn't. I know, this is a pretty normal requirement. Please check my code to see where I could be wrong.
    ReleaseCO (in PFR):-
    if (pageContext.getParameter("Apply") != null)
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    OAViewObject vo = (OAViewObject)am.findViewObject("CxPoReleaseVO1");
    Number poHeaderId = (Number)vo.getCurrentRow().getAttribute("PoHeaderId");
    String poNumber = (String)vo.getCurrentRow().getAttribute("PoNumber");
    OAViewObject linesVO = (OAViewObject)am.findViewObject("CxPoReleaseLinesVO1");
    Number lineAmt = (Number)linesVO.getCurrentRow().getAttribute("Amount");
    Serializable [] params = {poHeaderId.toString(), poNumber, lineAmt.toString()};
    am.invokeMethod("apply", params);
    ReleaseAM:-
    public void apply(String poheaderId, String poNumber, String lineAmt)
    Number blanketAmt, totalreleasesAmt, lineRlsAmt;
    try
    { lineRlsAmt = new Number(lineAmt.trim());}
    catch(Exception e) { throw new OAException("AK", "FWK_TBX_INVALID_EMP_NUMBER"); }
    totalreleasesAmt = getReleasesAmt(poheaderId);
    blanketAmt = getBlanketAmt(poNumber);
    if ((lineRlsAmt.intValue() - (blanketAmt.intValue()-totalreleasesAmt.intValue())) <= 0)
    getTransaction().commit();
    approve();
    throw new OAException("The amount is less than the remaining release amt", OAException.INFORMATION);
    } // end apply()
    public Number getReleasesAmt (String poHeaderId)
    CxTotalReleaseQuantityVVOImpl totalreleaseqtyVO = getCxTotalReleaseQuantityVVO1(); //vo to get TotalReleased Amount
    Number poHeadNum = null;
    Number totalqty;
    try { poHeadNum = new Number(poHeaderId); }
    catch (Exception e) { throw OAException.wrapperException(e); }
    totalreleaseqtyVO.initQuery(poHeadNum);
    CxTotalReleaseQuantityVVORowImpl row = null;
    row = (CxTotalReleaseQuantityVVORowImpl)totalreleaseqtyVO.getCurrentRow();
    try { totalqty = (Number)row.getQuantityReleased();}
    catch (Exception e) { throw new OAException(e.getMessage()); }
    if(totalqty != null)
    { return totalqty;  }
    else
    { throw new OAException ("exception occurred", OAException.ERROR);  }
    public Number getBlanketAmt (String poNumber)
    Number blanketAmt;
    CxBlanketAmtVOImpl blanketVO = (CxBlanketAmtVOImpl) getCxBlanketAmtVO1(); //VO to get total amount on the BlanketPO.
    blanketVO.initQuery(poNumber);
    Row row = blanketVO.getCurrentRow();
    blanketAmt = (Number)row.getAttribute("Quantity"); //gets the blanket amt
    if( blanketAmt != null ) {
    return blanketAmt ; }
    else { throw new OAException ("exception occurred", OAException.ERROR);   }
    ---------The code breaks at the line where I try to get "totalqty" or "blanketAmt" .. It throws a java nullpointer exception.
    Thanks for helping me out.
    -Vikram

    Hi Sumit,
    Thanks for replying. Here is the error stack.
    Exception Details.
    oracle.apps.fnd.framework.OAException: java.lang.NullPointerException
         at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:891)
         at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:865)
         at oracle.apps.fnd.framework.OAException.wrapperInvocationTargetException(OAException.java:988)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:211)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:749)
         at netflix.oracle.apps.nflix.p2p.po.webui.NfCreateReleaseCO.processFormRequest(NfCreateReleaseCO.java:115)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:810)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1159)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1022)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:988)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:843)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1022)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:988)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:843)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2675)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1682)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:508)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:429)
         at OA.jspService(OA.jsp:34)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    ## Detail 0 ##
    java.lang.NullPointerException
         at netflix.oracle.apps.nflix.p2p.po.server.NfReleaseCreateAMImpl.getReleasesAmt(NfReleaseCreateAMImpl.java:642)
         at netflix.oracle.apps.nflix.p2p.po.server.NfReleaseCreateAMImpl.apply(NfReleaseCreateAMImpl.java:302)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:190)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:749)
         at netflix.oracle.apps.nflix.p2p.po.webui.NfCreateReleaseCO.processFormRequest(NfCreateReleaseCO.java:115)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:810)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1159)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1022)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:988)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:843)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1022)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:988)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:843)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2675)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1682)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:508)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:429)
         at OA.jspService(OA.jsp:34)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    java.lang.NullPointerException
         at netflix.oracle.apps.nflix.p2p.po.server.NfReleaseCreateAMImpl.getReleasesAmt(NfReleaseCreateAMImpl.java:642)
         at netflix.oracle.apps.nflix.p2p.po.server.NfReleaseCreateAMImpl.apply(NfReleaseCreateAMImpl.java:302)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:190)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:749)
         at netflix.oracle.apps.nflix.p2p.po.webui.NfCreateReleaseCO.processFormRequest(NfCreateReleaseCO.java:115)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:810)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1159)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1022)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:988)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:843)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1022)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:988)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:843)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2675)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1682)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:508)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:429)
         at OA.jspService(OA.jsp:34)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    The code breaks at the line 642: totalqty = (Number)row.getQuantityReleased();
    I had already taken care of the null value in the VO sql query by using nvl(sum(release_amount), 0).. .so it should return atleast 0, if its null. But it returns "null" all the time.
    I dont understand why its doing that. When I run the sql backend the query works fine and returns 0,even when there are no prior releases on the PO.
    Thanks,
    Vikram

  • OIM 11G, DSML integration failing  with null pointer exception

    Hi,
    we are facing the similar probelm while sending a request from TIBCO BW to OIM 11G (Which is weblogic)
    The below request from TIBCO is not working and thowing a NULL POINTER EXCEPTION
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header>
    <ns:OIMUser xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="http://xmlns.oracle.com/OIM/provisioning" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">
    <ns:OIMUserId>xelsysadm</ns:OIMUserId>
    <ns:OIMUserPassword>Welcome123</ns:OIMUserPassword>
    </ns:OIMUser>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
    <ns0:processRequest xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://xmlns.oracle.com/OIM/provisioning">
    <sOAPElement xmlns="">
    <ns:modifyRequest xmlns:ns="urn:oasis:names:tc:SPML:2:0" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" returnData="data">
    <ns:psoID ID="Users:21"/>
    <ns:modification name="Users.User ID" operation="add">
    <ns:value>Richard1</ns:value>
    </ns:modification>
    </ns:modifyRequest>
    </sOAPElement>
    </ns0:processRequest>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    But if we change the <sOAPElement xmlns=""> to <sOAPElement> (removing the empty namespace) we can able to fire this soap.
    Could you please let me know are there any patch, workaround for this issue.
    Thanks
    Madhu

    I don't think OIM 11g supports DSML profile and may be that's the reason you are getting NPE.
    See: http://docs.oracle.com/cd/E14571_01/doc.1111/e14309/spmlapi.htm#CHDCBJAI
    It states:
    "SPML has two profiles: the XSD profile and the DSML profile. This release of Oracle Identity Manager makes use of the XSD profile."

  • Null Pointer Exception While calling function

    Excuse my ignorance, as I just started programming in Java, but while trying to give control to a function other than main(), I get a null pointer exception. I don't think that I'm calling the function properly, because I feel that I may need to start a new thread, but I don't know how to go about it. Please help.
    Here's the code(not the whole thing, just the important part):
    public static void main(){
    //some stuff to run     
    mainplace();
    public static void mainplace(){
    //stuff is in here
    }

    firstly the first main . Is this a typo
    shouldn't it be
    public static void main(String [] args) {
      mainplace();
    I say this cuz when u complile a class and try running it the first thing that gets called is the main method  with String[]  as the arguments.
    public static void mainplace() {
    // some thing here
    }it would be better if u post the code cuz, frankly nothing can be understood from ur previous post.
    there could be many reasons for the NullPointerException.
    sien

Maybe you are looking for

  • Error code when e-mailing

    Hey everyone I'm having some problems with my work e-mail coming through at home and wonder if anyone can help me. I am trying to e-mail a Polish address and keep getting the following error code 550..... Remote host said: 550 Please%see%http://www.o

  • Print program of the standard tcode

    Hi Expert, I am looking into the tcode F.27, so can you please tell which standard sap script is used in this transaction ? Thanks.

  • Returning the string from the SimpleDateFormat

    Hi guys, Can someone tell me how to return the string from the SimpleDateFormat? I've created the method to do this, but i don't know the exact code to use. Here's my code so far...     public String convert (Calendar gc)         String s = convert(g

  • Photo replacement not working

    i've replaced a photo in my project, but it doesn't show the new photo. it just shows the previous photo for longer, why? I've tried adding the photo instead and it just won't show up in preview.

  • 0 manual price on price list not synched to webtools

    Hi, Within some of our b1 price lists we have some item prices set to 0, i.e. the items are free of charge. However, these 0 value records are not synched into the webtools database, resulting in customers assigned to these price lists actually picki