将向量添加到空 JcomboBox
我正在开发一个与mysql集成的程序。
我正在查询数据库并使用向量将结果填充到 JcomboBox 中。这是在 GUI 构建完成并且工作正常时完成的。 根据第一个 JcomboBox 中选择的项目,我想填充第二个 JcomboBox。 我在第一个 JcomboBox 上使用操作侦听器,调用另一个类,传递第一个框中选定的项目,执行查询并将结果作为向量返回。
当我在第一种情况下使用向量时,我认为我可以直接调用
box2.addItem(vector2);
我的问题是,我将查询结果作为 [] 括起来的一个条目得到,
我很困惑,因为
JComboBox Box1 = new JComboBox(vector1);
可以在初始化时设置 JcomboBox,但我无法添加向量到空框可见后。
我可以使用 box2.addItem("new line etc"); 输入单行 但我想在框 1 中添加一条矢量线。
有人可以提示我我做错了什么吗?
I am working on a program that integrates with mysql.
I am querying the database and using a vector to populate a JcomboBox with the results . This is done as the GUI gets built and is working fine.
Based on the item chosen in the first JcomboBox I want to popultate the second JcomboBox.
I am using an action listener on the first JcomboBox, calling another class, passing the item selected in the first box, doing the query and returning the result as a vector.
As I used a vector in the first case I thought I could just call
box2.addItem(vector2);
My problem is that I get the result of the query as one entry enclosed by []
I am puzzled because
JComboBox Box1 = new JComboBox(vector1);
works to set up a JcomboBox at intitialisation but I cannot add a vector to an empty box after it has been made visible.
I can input single lines using box2.addItem("new line etc");
but I want to add a vector line in box 1.
Could someone give me a hint as to what I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,应该将向量结果添加到框 2 中。
结果包含大约 9 个值,但全部作为一行添加到框 2 中。
我需要生成的向量在单独的行中给出 9 个左右的值。
谢谢你们!
Sorry that should be add the vector result to box 2.
The result contains about 9 values but are all added as one line in box 2.
I need the resulting vector to give me the 9 or so values in separate lines.
Thanks guys!