| 发表于:2007-05-29 23:11:55 楼主 |
package yan1; import javax.swing.*; import javax.swing.table.*; import java.awt.*; import java.awt.event.*; //vist bbs java public class customer extends jframe { // variables of labels jlabel heading; jlabel labelcustno; jlabel labelcustname; jlabel labelcustsex; jlabel labelcustage; // variables for data entry controls jtextfield textcustno; jtextfield textcustname; jcombobox combocustsex; jtextfield textcustage; customer() { super( "customer "); container con; con = this.getcontentpane(); con.setlayout(new flowlayout()); // initializing textfield textcustno = new jtextfield(20); textcustname = new jtextfield(25); textcustage = new jtextfield(); string sex[] = { "male ", "female " }; combocustsex = new jcombobox(sex); // adding controls for customer number con.add(labelcustno); con.add(textcustno); // adding controls for customer name con.add(labelcustname); con.add(textcustname); // adding controls for customer sex con.add(labelcustsex); con.add(combocustsex); // adding controls for customer age con.add(labelcustage); con.add(textcustage); // close the program when close button is clicked setdefaultcloseoperation(exit_on_close); setsize(350, 250); show(); } public static void main(string[] args) { customer cust = new customer(); } } 错误提示为: exception in thread "main " java.lang.nullpointerexception at java.awt.container.addimpl(unknown source) at java.awt.container.add(unknown source) at yan1.customer. <init> (customer.java:42) at yan1.customer.main(customer.java:61) 请哪一位高手帮忙看啊~我调试了好久,小弟现在在学java开发环境是eclipse+myeclipse,jdk1.4 |
|
|
|
|