首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >awt eventqueue 0 nullpointerexception错误

awt eventqueue 0 nullpointerexception错误
EN

Stack Overflow用户
提问于 2013-03-21 07:34:03
回答 1查看 496关注 0票数 0

好的,我得到了这个错误,awt eventqueue 0 nullpointerexception error。当我尝试删除JPanel时。

令我困惑的是,当我删除另一个JPanel时,它工作得很好,但是这个不是。下面的第一个代码显示了JPanel,当我点击一个JButton时,它不会删除JPanel

代码语言:javascript
复制
public class buttontime implements ActionListener { //creating actionlistener for clicking on timebutton to bring up a combobox

    public void actionPerformed(ActionEvent clickTime) {
        Price priceObject = new Price();
        priceObject.getPricepanel();
        remove(priceObject.getPricepanel());
        priceObject.getPricepanel().revalidate();

        add(timeObject.getTimePanel(), BorderLayout.EAST);
        timeObject.getTimePanel().revalidate();


    }
}

//This one gives me 0 errors.
public class buttonprice implements ActionListener { //creating actionlistener for clicking on timebutton to bring up a combobox

    public void actionPerformed(ActionEvent ClickPrice) {


        Price priceObject = new Price();
        priceObject.SelectPrice();
        remove(timeObject.getTimePanel());
        timeObject.getTimePanel().revalidate();

        add(priceObject.getPricepanel(), BorderLayout.EAST);
        priceObject.getPricepanel().revalidate();


    }
}
EN

回答 1

Stack Overflow用户

发布于 2013-03-21 07:36:30

代码语言:javascript
复制
remove(priceObject.getPricepanel());

如果仅在删除此面板时获得NullPointerException,则priceObject.getPricepanel()必须返回null

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15536790

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档