Jcombobox与行的jtable问题

时间:2014-04-14 13:00:50

标签: java swing combobox jtable

当我选择第一行的第一个(组合框)列,并再次选择第二行的第二个(组合框)列时,第二个组合框中会出现相同的值。我尝试了很多方法,但没有找到任何解决方案。

// column11.setCellRenderer(new MyComboBoxRenderer(str));            // column11.setCellEditor(new MyComboBoxEditor(str));

        //column.setCellEditor(new ComboBoxCellEditor(comboBox2));
      //  comboBox2.setSelectedItem("s");
        //column11.setCellEditor(new DefaultCellEditor(comboBox2));

        //Set up tool tips for the sport cells.
       // DefaultTableCellRenderer renderer =
        //        new DefaultTableCellRenderer();
      //  renderer.setToolTipText("Click for combo box");

       // EachRowEditor11 rowEditor2 = new EachRowEditor11(tableMappingSheet);
      //  rowEditor2.setEditorAt(3, new DefaultCellEditor(comboBox2));
      //  rowEditor2.setEditorAt(4, new DefaultCellEditor(comboBox2));
     //   rowEditor2.setEditorAt(5, new DefaultCellEditor(comboBox2));
      //  tableMappingSheet.getColumnModel().getColumn(2).setCellEditor(rowEditor2);
      //  column11.setCellRenderer(renderer);
        /*MyCellRenderer test  = new MyCellRenderer();
        DefaultCellEditor defaultCellEditor=new DefaultCellEditor(comboBox2);
        JList jlist  = new JList(lst.toArray());
        column11.setCellEditor((TableCellEditor) test.getListCellRendererComponent(jlist, null, -1, true, true));
        */
        //lst.
       // column11.setCellRenderer(lst);

       // column11.setCellRenderer()
        Java2sAutoComboBox comboBox = new Java2sAutoComboBox(lst);
        comboBox.setDataList(lst);
        column11.setCellEditor(new DefaultCellEditor(comboBox));
       // tableMappingSheet.repaint();


        TableColumn columnForLookupValidation = tableMappingSheet.getColumnModel().getColumn(4);
         columnForLookupValidation.setCellEditor(new ComboBoxCellEditor(comboBoxForLookupValidation));
         //table.getColumnModel().addColumnModelListener(columnModelListener);

0 个答案:

没有答案