awt eventqueue 0 nullpointerexception错误 [英] awt eventqueue 0 nullpointerexception error
本文介绍了awt eventqueue 0 nullpointerexception错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的我收到此错误 awt eventqueue 0 nullpointerexception错误
。当我尝试删除 JPanel
时。
令我感到困惑的是,当我删除另一个 JPanel
时,它完全没问题但是这个没有。下面的第一个代码显示 JPanel
,当我点击 JButton
时,它不会删除的JPanel
。
public class buttontime实现ActionListener {//创建actionlistener,点击时间按钮调出一个组合框
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();
}
}
//这个给我0个错误。
公共类buttonprice实现ActionListener {//创建actionlistener,用于单击时间按钮以调出组合框
public void actionPerformed(ActionEvent ClickPrice){
价格price =新价格();
priceObject.SelectPrice();
remove(timeObject.getTimePanel());
timeObject.getTimePanel()。revalidate();
add(priceObject.getPricepanel(),BorderLayout.EAST);
priceObject.getPricepanel()。revalidate();
}
}
解决方案
除去(priceObject.getPricepanel());
如果你只得到 NullPointerException
删除此面板, priceObject.getPricepanel()
必须返回 null
。
Ok I'm getting this error awt eventqueue 0 nullpointerexception error
. When I try to remove a JPanel
.
Whats confusing me is when I remove another JPanel
it works perfectly fine but this one it doesn't. The first Code below shows the JPanel
that when I click on a JButton
it doesn't remove the JPanel
.
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();
}
}
解决方案
remove(priceObject.getPricepanel());
If you are getting a NullPointerException
only when removing this panel, priceObject.getPricepanel()
must be returning null
.
这篇关于awt eventqueue 0 nullpointerexception错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文