awt eventqueue 0 nullpointerexception错误
好的我收到此错误awt eventqueue 0 nullpointerexception error
。 当我尝试删除JPanel
。
令我感到困惑的是,当我删除另一个JPanel
它的工作原理非常好但是这个没有。 下面的第一个代码显示了JPanel
,当我点击JButton
它不会删除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());
如果仅在删除此面板时获得NullPointerException
,则priceObject.getPricepanel()
必须返回null
。