3
回答
为什么会出现Exception in thread "main" java.lang.NullPointerException

提示我如下异常:

Exception in thread "main" java.lang.NullPointerException

at Thepvc.<init><Thepv.java:25>

at Thepvc.main<Thepv.java:70>

请大家帮忙看下

代码如下


import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.awt.event.*;

class Thepvc extends Frame implements WindowListener
{
      
        Box   basebox ,box1,box2;
        Thepvc()
        { 
          
           box1=Box.createVerticalBox();
           box1.add(Box.createVerticalStrut(8));
           box1.add(new Label("第一步 导入人员资料  "));
           box1.add(new Label("第二步 选择照片位置  "));
           box1.add(Box.createVerticalStrut(8));
           box1.add(new Label("进行证卡验证"));
           box2=Box.createVerticalBox();
           box2.add(Box.createVerticalStrut(8));
           box2.add(new TextField(30));
           box2.add(Box.createVerticalStrut(8));
           box2.add(Box.createVerticalStrut(8));
           box2.add(new TextField(30));
           basebox.add(box1);
           basebox.add(Box.createHorizontalStrut(10));
           basebox.add(box2);
           add(basebox);
           setBounds(0,0,600,600);  
           setVisible(true);      
           addWindowListener(this);
           validate();          
        }
        public void windowActivated(WindowEvent e)
        {
     
        }
        public void windowDeactivated(WindowEvent e)
        {

                  setBounds(0,0,400,400);
                 validate();
            
        }
        public void windowClosing(WindowEvent e)
       {
                   dispose();
       }
       public void windowClosed(WindowEvent e)
       {
            System.exit(0);
       }
       public void windowIconified(WindowEvent e)
       {
       }
       public void windowDeiconified(WindowEvent e)
       {
                setBounds(0,0,400,400);
                validate();
       }
       public void windowOpened(WindowEvent e){}
 }
  public class Thepv
    {
           public static void main(String[] args)
           {
                 new Thepvc();
            }
    }
举报
顶部