java如何向第二个组合框模型项添加数组值从第一个组合框所选项获取数组名称?
如何将数组值添加到第二个组合框模型项中,从第一个组合框所选项中获取数组名称
String[] one = new String[]{"A","B"};
String[] two = new String[]{"C","D"};
String[] three = new String[]{"12500","13500"};
String[] four = new String[]{"Scale_1","Scale_2"};
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
String Value=(String)jComboBox1.getSelectedItem();
DefaultComboBoxModel dm=new DefaultComboBoxModel(Value); // here is the error
jComboBox2.setModel(dm);
}
错误显示
no suitable constructor found for DefaultComboBoxModel(String).
# 1 楼答案
通过这种方式,您可以从第一个组合框中获取所选项并将其添加到第二个组合框中,但我认为您无法返回数组名称