我的 UI 设计中有一个列表框,但是,我无法访问许多人在实现 get 方法时似乎正在访问的 .getElement()
方法。
这有什么原因吗?有没有办法向此列表框添加值?
最佳答案
I have a List box in my UI design,
我假设您指的是使用 Swing 时的 JList
。 “列表”是一个 AWT 组件。提出问题时要具体,以避免混淆。
Is there any reason for this and is there a way to add values to this list box?
您将项目添加到 DefaultListModel
,而不是 JList
。
阅读 Swing 教程中关于 How to Use Lists 的部分了解更多信息和工作示例。
关于java - 无法添加到列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36900229/