辣椒风暴 2020-03-02 11:36 采纳率: 0%
浏览 248

JComboBox addItem无法识别

idea中输入的代码,软件表示无法识别,求解决方案


想在JComboBox中加入元素,如下图,发现无法识别addItem;
idea预设版本与所用JDK版本一致


图片说明


    JComboBox c1=new JComboBox();
    c1.addItem("suit one");
    c1.addItem("suit two");

附addItem JDK13.0.2:


addItem

public void addItem​(E item)

Adds an item to the item list. This method works only if the JComboBox uses a mutable data model.
Warning: Focus and keyboard navigation problems may arise if you add duplicate String objects. A workaround is to add new objects instead of String objects and make sure that the toString() method is defined. For example:

comboBox.addItem(makeObj("Item 1"));

comboBox.addItem(makeObj("Item 1"));

...

private Object makeObj(final String item) {
return new Object() { public String toString() { return item; } };
}

Parameters:

item - the item to add to the list

  • 写回答

1条回答 默认 最新

  • 星尘埃及 2023-06-28 14:53
    关注

    intellij idea的Java无法识别addItem是因为什么

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题