NullPointerException吧?
要先判断一下取到的是不是null:        if (componentsajleft[i] instanceof JComboBox){
            Object value = ((JComboBox) componentsajleft[i]).getEditor().getItem();
            if (value != null && value.toString().trim().length() == 0){
                //......
            }
        }
        

解决方案 »

  1.   

    不行,如果我的jcombobox里是空的话,
    Object value = ((JComboBox) componentsajleft[i]).getEditor().getItem(),每次取到的值都是空值。
    如果我从下拉框中选一个值,可以进行下部操作。如果不选,则出错。他也没提示是什么异常。
      

  2.   

    你可以尝试下用捕捉异常的方法来做.if (componentsajleft[i].getClass() == JComboBox.class){
      try{
        Object value = ((JComboBox) componentsajleft[i]).getEditor().getItem();
        //...
      }catch(Exception e){
        Object value = ...
        //...
      }
    }如果是出现了异常,自然就会运行CATCH内的代码.
      

  3.   

    我认为这是实现的问题,为什么一定要反向得到呢,我有点奇怪,再说,, 本身JComboBox
    不是就有ComboBoxModel ,用它去作不是更好吗,我的意思就是,你可以先得到model然后再去判断