[英]How to store multiple values in a JTable row as a JCombobox
Hashmap contains key and value(result of parsing an XML). Hashmap包含键和值(解析XML的结果)。 Hashmap contains things in the way that key is a string and value is a vector.
Hashmap包含以下内容:键是字符串,值是向量。 A key may have single value in the vector or mutiple values in the vector.
键可以在向量中具有单个值,也可以在向量中具有多个值。
My question is: 我的问题是:
This hashmap, has to be put into a jtable,such that if the key has single value, put it to text box. 必须将此哈希图放入jtable中,以便如果键具有单个值,则将其放入文本框。 If it has multiple values insert a combobox in the row of that table.
如果它具有多个值,则在该表的行中插入一个组合框。
I need the swing code for this problem 我需要这个问题的代码
Not code but steps that can help you.. 不是代码,而是可以帮助您的步骤。
References that can help you:- 可以帮助您的参考:
You can make a HashMap<String, Vector<ValueType>> which maps a String key to a Vector. 您可以创建HashMap <String,Vector <ValueType >>,将String键映射到Vector。 In this case, even a single value will be stored in a Vector, and when you add the first element for a hash key, you have to make a vector, add the element to it, and put the vector with the key.
在这种情况下,即使单个值也将存储在Vector中,并且当您为哈希键添加第一个元素时,您必须制作一个vector,将其添加到该元素中,然后将矢量与键一起放入。 Subsequently you can just add to the vector.
随后,您可以将其添加到向量中。 For display, determine if the Vector has 1 or more elements to decide which UI to use.
为了显示,请确定Vector是否具有1个或多个元素来决定使用哪个UI。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.