如何正确使用removeAllItems() [英] How to Use removeAllItems() without error

查看:346
本文介绍了如何正确使用removeAllItems()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JComboBox .. 删除了JComboBox中的所有项目.我在"ItemStateChanged"事件中使用了"removeAllItems()",但在更改项目时在运行时 出现" java.lang.NullPointerException "错误..但是该组件具有不为null的项目,但错误来了..我找不到原因..?

请通过正确的实现来帮助我.

I used JComboBox.. to remove all the items in the JComboBox. I used ''removeAllItems()'' in ''ItemStateChanged'' event but in runtime while changing items "java.lang.NullPointerException" error occurs.. but the component has items it''s not null, but the error comes.. I can''t find why..?

Please help me by giving a correct implementation for it.

推荐答案

java.lang.NullPointerException
这仅表示您正在尝试访问NULL的对象的属性.

有关完整的详细信息,请在此处. [ ^ ]

简单使用DEBUGGER可以告诉您在引发错误的行上哪个对象为null.找到并处理.
java.lang.NullPointerException
This simply means that you are trying to access a property of an object that is NULL.

For full details, look here.[^]

A simple use of DEBUGGER can tell you which object is null on the line that is throwing the error. Find it and handle it.


这篇关于如何正确使用removeAllItems()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆