[英]Can I create List of comboBox type?
Good day everybody 大家好
Can I create List of JCombobox type .. and fill it with comboBoxes like this or something ? 我可以创建JCombobox类型..的列表并用类似这样的comboBoxes填充它吗?
List<JCombobox> comboBoxList = new arrayList<JComboBox>();
comboBoxList.add(JComboBox);
or something like above??? 或类似的东西???
Yes you can have an ArrayList
which can contain JComboBox
type elements 是的,您可以拥有一个可以包含JComboBox
类型元素的ArrayList
You can create ArrayList like this: 您可以像这样创建ArrayList:
List<JComboBox> comboBoxList = new ArrayList<>(); // you can also provide capacity here
And then you can create JComboBox instances by using any of the constructors 然后,您可以使用任何构造函数创建JComboBox实例
JComboBox combo1 = new JComboBox();
// set properties of JComboBox here
And then you can add this to your comboBoxList
by 然后您可以将其添加到您的comboBoxList
comboBoxList.add(combo1);
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.