Exception in thread "main" java.lang.NullPointerException
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
/*
* UserInterface.java
* @author tristan
* Created on April 15, 2007, 5:45 PM
*/
publicclass UserInterfaceextends JFrameimplements ActionListener{
//Declare member variables
private JLabel monthLabel =new JLabel();
private JTextField month =new JTextField();
private JLabel dayLabel =new JLabel();
private JTextField day =new JTextField();
private JLabel yearLabel =new JLabel();
private JTextField year =new JTextField();
//CalendarManager
private JTextArea entry =new JTextArea();
private JButton saveEntry;
private JButton getEntry;
public UserInterface(){
//... Build the content pane.
Container content = this.getContentPane();
content.add(monthLabel);// Add components to the content
content.add(month);
content.add(dayLabel);
content.add(day);
content.add(yearLabel);
content.add(year);
content.add(entry);
content.add(saveEntry);
content.add(getEntry);
this.setTitle("Calendar Program");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();// does layout of components.
}//end constructor
publicstaticvoid main(String[] args){
JFrame window =new UserInterface();
window.setVisible(true);
}
publicvoid actionPerformed(ActionEvent e){
}
}
I've never had this happen before. Why am I getting a null exception? The full error is: Exception in thread"main" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1027)
at java.awt.Container.add(Container.java:352)
at UserInterface.<init>(UserInterface.java:34)
at UserInterface.main(UserInterface.java:55)

