Java 使用GET时在netbeans中引发异常

Java 使用GET时在netbeans中引发异常,java,swing,exception,netbeans,Java,Swing,Exception,Netbeans,我试图通过GET将数据从模型类检索到textfield中,尽管nullpointexception抛出了一个错误 视图类中的代码为= public View_EditCustomer(Model_Customer cust) { customer = cust; txtname.setText(customer.GetFName()); txtSecondName.setText(customer.GetLName()); i

我试图通过GET将数据从模型类检索到textfield中,尽管nullpointexception抛出了一个错误

视图类中的代码为=

  public View_EditCustomer(Model_Customer cust) {
        customer = cust;
        txtname.setText(customer.GetFName());
        txtSecondName.setText(customer.GetLName());

        initComponents();
    }
在另一个视图类中,它是=

private void btnSelectActionPerformed(java.awt.event.ActionEvent evt) {                                          
      ListSelectionModel rowSM = jTable1.getSelectionModel();
            int row = rowSM.getMinSelectionIndex();
            int Appointment_ID = (Integer)resultModel.getValueAt(row, 0);
            Model_Customer cust = null;
            try{
                cust = Controller_ManageCustomer.GetCustomer(Appointment_ID);
                new View_EditCustomer(cust).setVisible(true); 
            }catch(Exception ex){
                JOptionPane.showMessageDialog(this,ex.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
            }
    }          
型号\客户代码部件=

  public static Model_Customer QueryID(int Appointment_ID) throws Exception
    {
        try{
            Statement stmt = Model_Customer.conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM appointment WHERE appointmentid="+Appointment_ID+" LIMIT 1;");
            if(rs.next())
                return new  Model_Customer(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8),rs.getString(9),rs.getString(10),rs.getString(11),rs.getString(12));
        }catch(Exception e){
            throw new Exception(e.getMessage());
        }
        return null;
}


private Model_Customer(int Appointment_ID, String FName, String LName, String Registration, String Make, String Model, String Engine, String Year, String Mileage, String Type, String Date, String Time)
    {
        this._Appointment_ID=Appointment_ID;
        this._Type=Type;
        this._Time=Time;
        this._Date=Date;
        this._FName=FName;
        this._LName=LName;
        this._Make=Make;
        this._Model=Model;
        this._Engine=Engine;
        this._Year=Year;
        this._Mileage=Mileage;
        this._Registration=Registration;
        this._inSync=true;    
    }
    public int GetID()
    {
        return this._Appointment_ID;
    }
    public String GetFName()
    {
        return _FName;
    }
    public String GetLName()
    {
        return _LName;
    }
    public String GetRegistration()
    {
        return _Registration;
    }

    public String GetMake()
    {
        return _Make;

    }
    public String GetModel()
    {
        return _Model;
    }


    public String GetEngine()
    {
        return _Engine;
    }
    public String GetYear()
    {
        return _Year;
    }
    public String GetMileage()
    {
        return _Mileage;
    }
    public String GetType()
    {
        return _Type;
    }
    public String GetDate()
    {
        return _Date;
    }
    public String GetTime()
    {
        return _Time;
    }
在调试模型_中,Customer cust实际上由数据填充,它实际上位于txtname.setText(Customer.GetFName())的末尾;转到Model_Customer GetFName并应检索名称,但引发异常(int)0。非常感谢你的帮助

不应该初始化组件();是否在使用文本视图之前调用

public View_EditCustomer(Model_Customer cust) {

        initComponents();
        customer = cust;
        txtname.setText(customer.GetFName());
        txtSecondName.setText(customer.GetLName());


    }

请粘贴例外,以便查看详细信息。并发布模型类客户。您知道
NUllPointerException
的含义吗。如果你这样做了,只要看看它指向的那条线,找出为什么那条线会产生一个空值,试着把你的
initComponents
放在其他三行之前。该死的。。。我确信在英国编写代码已经太晚了:D你是100%正确的!谢谢