在一个组合框中显示值,该组合框取决于java netbeans中的另一个组合框

问题描述 投票:0回答:1

目前我正在开发一个表单,要求用户从名为floorCbo的组合框中选择一个特定的楼层。一旦用户选择了楼层,楼层的单位将出现在另一个名为unitCbo的组合框中。我已经尝试了下面的代码,但在floorCbo上选择楼层后,unitCbo组合框中似乎没有任何内容。

 private void floorCboActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
   String selectedvalue = floorCbo.getSelectedItem().toString();

   if  (floorCbo.equals("1ST FLOOR")){

       unitCbo.add(this, "UNIT 1A");
        unitCbo.add(this, "UNIT 1B");
         unitCbo.add(this, "UNIT 1C");
          unitCbo.add(this, "UNIT 1D");
           unitCbo.add(this, "UNI T1E");
   }


}          
java netbeans combobox
1个回答
0
投票

你的意思是有if (selectedvalue.equals("1ST FLOOR"))?目前,您正在检查组合框对象的相等性,而不是它的值

© www.soinside.com 2019 - 2024. All rights reserved.