如何从java中的combobox swing中获取价值?

时间:2015-12-29 17:51:14

标签: java eclipse swing

我有一项任务是创建一个创建顺序文件的swing GUI,以及另一个读取顺序文件的swing GUI。我不知道如何从组合框中获取价值。让我们说组合框的名称是comboBox_1,命令是什么?

      if ( studentID > 0 )  {

                //***********************
                output.writeUTF(textField.getText());
                output.writeUTF(textField_1.getText());
                output.writeUTF(textField_2.getText());
                output.writeInt(studentID);
                output.writeUTF(textField_4.getText());
                output.writeUTF(textField_5.getText());
                output.writeUTF(textField_6.getText());
                output.writeUTF(textField_7.getText());
                output.writeUTF(textField_8.getText());
                //PLACE FOR COMBOBOXES

                output.writeInt(maths);
                output.writeInt(buisness);
                output.writeInt(programming);
                output.writeInt(accounting);
                output.writeInt(art);
                output.writeInt(music);
              }

1 个答案:

答案 0 :(得分:0)

如果你的组合框包含字符串列表,你可以

(String)comboBox_1.getSelectedItem();