我正在使用一个绑定的JComboBox。我想知道的是如何检查JComboBox中是否有任何项。
谢谢您。
测试 JComboxBox 参考是 null ,您可以将其与 无效的 使用 == 接线员。要测试组合框是否包含任何项,可以使用instance方法 getItemCount ,它返回它包含的项目数。
JComboxBox
null
无效的
==
getItemCount
JComboxBox box = ... boolean boxIsNull = (box == null); // answers the title of the question boolean boxHasItems = (box.getItemCount() > 0);