【问题标题】:Make a selection in one jcombobox enable a different jcombobox在一个 jcombobox 中进行选择 启用不同的 jcombobox
【发布时间】:2011-03-21 10:45:34
【问题描述】:

我有 7 个 jcombobox,它们都以相同的默认选择开头。如果在前面的 jcombobox 中选择了默认值以外的其他内容,如何启用下一个?

        if ( ! (custData1.equals("Please Select a Customer from the dropdown menu")) ){
        custData2.setEnabled(true);
        if ( ! (custData2.equals("Please Select a Customer from the dropdown menu")) ){
            custData3.setEnabled(true);
            if ( ! (custData3.equals("Please Select a Customer from the dropdown menu")) ){
            custData4.setEnabled(true);
            if ( ! (custData4.equals("Please Select a Customer from the dropdown menu")) ){
            custData5.setEnabled(true);
            if ( ! (custData5.equals("Please Select a Customer from the dropdown menu")) ){
            custData6.setEnabled(true);
            if ( ! (custData6.equals("Please Select a Customer from the dropdown menu")) ){
            custData7.setEnabled(true);
            }
           }
          }
         }
        }
    }

这似乎不起作用...

【问题讨论】:

    标签: java swing jcombobox


    【解决方案1】:

    通过扩展JComboBox 创建自定义JComboBox。使该类引用对前面的组合框。 Have it and itself as an ActionListener to the preceding box and whenever an item is selected it should enable/disable itself.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-28
      • 2023-03-30
      • 2011-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多