将jcombobox值与jtextfield值链接 [英] linking jcombobox values with jtextfield values

查看:109
本文介绍了将jcombobox值与jtextfield值链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在netbeans IDE 6.9中创建了一个应用程序,在其中我需要为jcombobox中的每个值设置值.在我的窗格中,有一个组合框,下面是用于为组合框中的每个值输入值的文本字段.谁能建议我如何将组合框链接到文本字段.我的意思是组合框中的每个值都有不同的值.我希望用户在组合框中选择一个值,然后应显示其对应的值(如果已经输入),否则应显示一个空格.我希望每个组合框值的所有值都应一次性设置(用户不应按确定"按钮). -预先感谢

I've created an application in netbeans IDE 6.9 where I need to set values for each value in the jcombobox. In my pane I've a combobox and below that are the textfields for entering values for each value in the combobox. Can anyone suggest that how do I link the combobox with textfield. I mean there are different values for each value in the combobox. I want that user selects a value in the combobox then its corresponding value should be displayed(if it has already been entered) otherwise a blank space should be shown. I want that all the values for each combobox values should be set in one go(the user should not press the ok button). -Thanks in advance

推荐答案

我只能从问题中猜出组合框中的每个项目都是一个对象,并且您要编辑所选项目的多个字段.

I can only guess from the question that each item in your combo box is an object and you want to edit multiple fields of the selected item.

可以使用一堆单独的文本字段,每个文本字段用于所选组合框中的值"中的每个值".

You could use a bunch of individual text fields, one for each "value" in the selected "value in the combobox".

更好的UI将是用于列出和编辑字段的属性窗格. JIDE网格中的商业广告PropertyGrid实际上可以将组合框和属性窗格组合在一起

A better UI would be a property pane to list and edit the fields. The commercial PropertyGrid in JIDE Grids can actually combine the combobox and property pane in one place.

您可以在输入每个字段值后提交,也可以在编辑器失去焦点时(例如,在组合中选择另一个项目时)全部提交.

You can commit each field value after it is entered, or commit all when the editor loses focus (for example when you select another item in the combo).

这篇关于将jcombobox值与jtextfield值链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆