当前位置: 技术问答>java相关
关于java调试的问题(用jdk4.0 和 JCreator Pro V2.00)
来源: 互联网 发布时间:2015-10-09
本文导语: import javax.swing .*; import java.awt.*; public class Test{ static JFrame theFrame; static JPanel panel; JLabel lableName; JLabel lableAge; JLabel lableBirthday; JLabel lableSex; JTextField textName; JTextField textAge; JTextField textBirthday; JComboBox...
import javax.swing .*;
import java.awt.*;
public class Test{
static JFrame theFrame;
static JPanel panel;
JLabel lableName;
JLabel lableAge;
JLabel lableBirthday;
JLabel lableSex;
JTextField textName;
JTextField textAge;
JTextField textBirthday;
JComboBox comboDetails;
public Test(){
panel=new JPanel();
theFrame.getContentPane().add(panel);
lableName=new JLabel("pleas enter your name");
lableAge=new JLabel("your age is ");
lableBirthday=new JLabel("please enter your birthday");
textAge=new JTextField(2);
textBirthday=new JTextField(5);
textName=new JTextField(3);
String sex[]={"male","female"};
comboDetails=new JComboBox(sex);
panel.add(lableName);
panel.add(textName);
panel.add(lableAge);
panel.add(textAge);
panel.add(lableBirthday);
panel.add(textBirthday);
panel.add(lableSex);
panel.add(comboDetails);
}
public static void main(String[] args){
theFrame=new JFrame("Personnal Details");
Test a;
a=new Test();
theFrame.setVisible(true);
theFrame.setSize(400,300);
}
}
编译通过了,可是无法运行,以下是错误信息:
Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:439)
at java.awt.Container.add(Container.java:298)
at Test.(test.java:42)
at Test.main(test.java:50)
如果只用jdk调试的话,也是无法运行
J:javaj2sdk4.0bin>javac Test.java
J:javaj2sdk4.0bin>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test
哪位大虾帮帮我,这是怎么回事?
import java.awt.*;
public class Test{
static JFrame theFrame;
static JPanel panel;
JLabel lableName;
JLabel lableAge;
JLabel lableBirthday;
JLabel lableSex;
JTextField textName;
JTextField textAge;
JTextField textBirthday;
JComboBox comboDetails;
public Test(){
panel=new JPanel();
theFrame.getContentPane().add(panel);
lableName=new JLabel("pleas enter your name");
lableAge=new JLabel("your age is ");
lableBirthday=new JLabel("please enter your birthday");
textAge=new JTextField(2);
textBirthday=new JTextField(5);
textName=new JTextField(3);
String sex[]={"male","female"};
comboDetails=new JComboBox(sex);
panel.add(lableName);
panel.add(textName);
panel.add(lableAge);
panel.add(textAge);
panel.add(lableBirthday);
panel.add(textBirthday);
panel.add(lableSex);
panel.add(comboDetails);
}
public static void main(String[] args){
theFrame=new JFrame("Personnal Details");
Test a;
a=new Test();
theFrame.setVisible(true);
theFrame.setSize(400,300);
}
}
编译通过了,可是无法运行,以下是错误信息:
Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:439)
at java.awt.Container.add(Container.java:298)
at Test.(test.java:42)
at Test.main(test.java:50)
如果只用jdk调试的话,也是无法运行
J:javaj2sdk4.0bin>javac Test.java
J:javaj2sdk4.0bin>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test
哪位大虾帮帮我,这是怎么回事?
|
import javax.swing .*;
import java.awt.*;
public class Test{
static JFrame theFrame;
static JPanel panel;
JLabel lableName;
JLabel lableAge;
JLabel lableBirthday;
JLabel lableSex;
JTextField textName;
JTextField textAge;
JTextField textBirthday;
JComboBox comboDetails;
public Test(){
panel=new JPanel();
theFrame.getContentPane().add(panel);
lableName=new JLabel("pleas enter your name");
lableAge=new
lableSex = new JLabel("your sex is "); //
import java.awt.*;
public class Test{
static JFrame theFrame;
static JPanel panel;
JLabel lableName;
JLabel lableAge;
JLabel lableBirthday;
JLabel lableSex;
JTextField textName;
JTextField textAge;
JTextField textBirthday;
JComboBox comboDetails;
public Test(){
panel=new JPanel();
theFrame.getContentPane().add(panel);
lableName=new JLabel("pleas enter your name");
lableAge=new
lableSex = new JLabel("your sex is "); //