Exception in thread "main" java.lang.NullPointerException
hey everyone... i m new to java.. and i am working on Jframe builder. i have encountered some errors in the code given below:
/************************************************** **************/
/* checknumber */
/* */
/************************************************** **************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Summary description for checknumber
*
*/
public class checknumber extends JFrame
{
// Variables declaration
private JLabel jLabel1;
private JTextField jTextField1;
private JButton jButton1;
private JButton jButton2;
private JPanel contentPane;
double i;
// End of variables declaration
public checknumber()
{
super();
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//
this.setVisible(true);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always regenerated
* by the Windows Form Designer. Otherwise, retrieving design might not work properly.
* Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
* to retrieve your design properly in future, before revising this method.
*/
private void initializeComponent()
{
jLabel1 = new JLabel();
jTextField1 = new JTextField();
jButton1 = new JButton();
contentPane = (JPanel)this.getContentPane();
//
// jLabel1
//
//
// jTextField1
//
jTextField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1_actionPerformed(e);
}
});
//
// jButton1
//
jButton1.setText("check");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
jButton2.setText("redo");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton2_actionPerformed(e);
}
});
//
// contentPane
//
contentPane.setLayout(null);
addComponent(contentPane, jLabel1, 139,306,193,37);
addComponent(contentPane, jTextField1, 163,78,138,22);
addComponent(contentPane, jButton1, 189,198,83,28);
addComponent(contentPane, jButton2, 250,200,83,28);
//
// checknumber
//
this.setTitle("checknumber - extends JFrame");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(473, 544));
}
/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
private void jTextField1_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField1_actionPerformed( ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jButton1_actionPerformed(ActionEvent e)
{ i= Double.parseDouble(jTextField1.getText());
/* if (i<0)
{ jLabel1.setText("Number is a negative integer");
}*/
System.out.println("\njButton1_actionPerformed(Act ionEvent e) called.");
// TODO: Add any handling code here
}
private void jButton2_actionPerformed(ActionEvent e)
{ jTextField1.setText(" ");
System.out.println("\njButton1_actionPerformed(Act ionEvent e) called.");
}
//
// TODO: Add any method code to meet your needs in the following area
//
//============================= Testing ================================//
//= =//
//= The following main method is just for testing this class you built.=//
//= After testing,you may simply delete it. =//
//================================================== ====================//
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf. windows.WindowsLookAndFeel");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
new checknumber();
}
//= End of Testing =
}
and the errors are :
init:
deps-jar:
compile-single:
run-single:
Exception in thread "main" java.lang.NullPointerException
at checknumber.initializeComponent(checknumber.java:7 3)
at checknumber.<init>(checknumber.java:27)
at checknumber.main(checknumber.java:182)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
please help me out with this..:(