如何在netbeans中获取JList以从模型中的向量中获取数据?

时间:2021-12-23 07:30:40

I'm a fairly experienced Java user, but I've just started trying to use NetBeans to build a GUI. Previously I coded GUIs by hand, but this is a bit of a bigger project.

我是一个相当有经验的Java用户,但我刚开始尝试使用NetBeans来构建GUI。以前我手工编写了GUI,但这是一个更大的项目。

Anyways, I have a Vector in my model (MVC design), and I want to make the list populate with elements in my vector. I know how I'd do this by hand- I'd initiate the list like so:

无论如何,我的模型中有一个Vector(MVC设计),我想让列表填充我的向量中的元素。我知道我是如何手工做的 - 我会像这样启动列表:

JList list = new JList(model.getVector());

JList list = new JList(model.getVector());

But the problem is that I can't edit the part of the code that netbeans uses to initialize components.... So I was wondering how I would go about using the IDE to grab this vector in its initiation....I assume it has something to do with editing the properties, but I couldn't see anything entirely promising.

但问题是我无法编辑netbeans用于初始化组件的代码部分....所以我想知道如何在启动时使用IDE来抓取这个向量....我假设它与编辑属性有关,但我看不到任何完全有希望的东西。

Thanks!

1 个解决方案

#1


Read the suggestion by mmyers; I googled for "custom creation code" and figured it out-

阅读mmyers的建议;我用Google搜索“自定义创建代码”并将其计算出来 -

I right clicked the list in the Design view, clicked on "Customize Code," and on the initialization part, I changed the dropdownbox to "custom creation" and edited the code by hand :P

我右键单击设计视图中的列表,单击“自定义代码”,在初始化部分,我将下拉框更改为“自定义创建”并手动编辑代码:P

#1


Read the suggestion by mmyers; I googled for "custom creation code" and figured it out-

阅读mmyers的建议;我用Google搜索“自定义创建代码”并将其计算出来 -

I right clicked the list in the Design view, clicked on "Customize Code," and on the initialization part, I changed the dropdownbox to "custom creation" and edited the code by hand :P

我右键单击设计视图中的列表,单击“自定义代码”,在初始化部分,我将下拉框更改为“自定义创建”并手动编辑代码:P