| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 999 人关注过本帖
标题:"AWT-EventQueue-0" java.lang.NullPointerException 错误
只看楼主 加入收藏
oofire
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-5-26
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:2 
"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.(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.(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.(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 
2010-09-27 09:18
gameohyes
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:53
帖 子:1275
专家分:3629
注 册:2009-3-5
收藏
得分:3 
空指向异常.可能的原因有:对象没有被实例化,对象中没有元素而你又去访问了它的某一元素
设断点慢慢找..

C#超级群 74862681,欢迎大家的到来!
2010-09-27 19:03
llooppzhang
Rank: 7Rank: 7Rank: 7
来 自:江苏
等 级:黑侠
威 望:5
帖 子:308
专家分:518
注 册:2009-10-18
收藏
得分:3 
看不出,还是自己找吧。
2010-09-29 10:16
快速回复:"AWT-EventQueue-0" java.lang.NullPointerException 错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037360 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved