当前位置: 代码迷 >> Java相关 >> "AWT-EventQueue-0" java.lang.NullPointerException 错误
  详细解决方案

"AWT-EventQueue-0" java.lang.NullPointerException 错误

热度:1165   发布时间:2010-09-27 09:18:57.0
"AWT-EventQueue-0" java.lang.NullPointerException 错误
    //计算按钮的事件监听类
    private class CalculateButtonActionListener implements ActionListener {
        public void actionPerformed(final ActionEvent e) {
            int uid = Integer.parseInt(keHuBianHao.getText().trim());
            int thisyear = nianFen.getSelectedIndex() + 2008;
            int thismonth = yueFen.getSelectedIndex() + 1;
            float yingJiaoFeiYong;
            float caiNuanFei;
            float reShuiFei;
            Parameter parameter = Dao.getParameter();

            int lastyear,lastmonth;
            if(thismonth == 1) {
                lastyear = thisyear - 1;
                lastmonth = 12;
            }else {
                lastyear = thisyear;
                lastmonth = thismonth - 1;
            }
            
            if(yongHuZhongLei.getSelectedIndex() == 0) {
                TbHeatKhHis thisMonthHis = new TbHeatKhHis();
                TbHeatKhHis lastMonthHis = new TbHeatKhHis();
                thisMonthHis = Dao.getMonthHeatKhHis(uid, thisyear, thismonth);
                lastMonthHis = Dao.getMonthHeatKhHis(uid, lastyear, lastmonth);
                if(yongHuXingZhi.getSelectedIndex() == 0) {
                    float thisMonthHeatDegree = Float.parseFloat(thisMonthHis.getHeatDegree());//278行
                    float lastMonthHeatDegree = Float.parseFloat(lastMonthHis.getHeatDegree());
                    float heatJumin = parameter.getHeatjumin();
                    caiNuanFei = (thisMonthHeatDegree - lastMonthHeatDegree)*heatJumin;
                //    caiNuanFei = (Float.parseFloat(thisMonthHis.getHeatDegree()) - Float.parseFloat(lastMonthHis.getHeatDegree()))*parameter.getHeatjumin();
                }else {
                    caiNuanFei = (Float.parseFloat(thisMonthHis.getHeatDegree()) - Float.parseFloat(lastMonthHis.getHeatDegree()))*parameter.getHeatfeijumin();
                }
                float temp = (Float.parseFloat(thisMonthHis.getGongShuiFlow()) - Float.parseFloat(lastMonthHis.getGongShuiFlow())) - (Float.parseFloat(thisMonthHis.getHuiShuiFlow()) - Float.parseFloat(lastMonthHis.getHuiShuiFlow()));
                if(temp >= 0) {
                    reShuiFei = temp * parameter.getHeatguding();
                }else {
                    reShuiFei = 0;
                }
                yingJiaoFeiYong = caiNuanFei + reShuiFei;
            }else {
                TbSteamKhHis thisMonthHis = new TbSteamKhHis();
                TbSteamKhHis lastMonthHis = new TbSteamKhHis();
                thisMonthHis = Dao.getMonthSteamKhHis(uid, thisyear, thismonth);
                lastMonthHis = Dao.getMonthSteamKhHis(uid, lastyear, lastmonth);
                if(yongHuXingZhi.getSelectedIndex() == 0) {
                    yingJiaoFeiYong = (Float.parseFloat(thisMonthHis.getHeatDegree()) - Float.parseFloat(lastMonthHis.getHeatDegree())) * parameter.getSteamjumin();
                }else {
                    yingJiaoFeiYong = (Float.parseFloat(thisMonthHis.getHeatDegree()) - Float.parseFloat(lastMonthHis.getHeatDegree())) * parameter.getSteamfeijumin();
                }
            }
            feiYong.setText(yingJiaoFeiYong + "");
        }
    }



出错信息:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
    at java.lang.Float.parseFloat(Unknown Source)
    at internalFrame.shuRuGuanLi.HeatShuRuPanel$CalculateButtonActionListener.actionPerformed(HeatShuRuPanel.java:278)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

请问下为什么出现这种错误
搜索更多相关的解决方案: java  lang  

----------------解决方案--------------------------------------------------------
空指向异常.可能的原因有:对象没有被实例化,对象中没有元素而你又去访问了它的某一元素
设断点慢慢找..
----------------解决方案--------------------------------------------------------
看不出,还是自己找吧。
----------------解决方案--------------------------------------------------------
  相关解决方案