0
votes

I have a table that accepts multi selection. On this jtable I add a column that I add a combobox like this:

public void setPriorityEditor(final String columnName) {
        final TableColumn col = ((BasicTableModel) table.getModel())
            .findTableColumn(columnName);
        col.setCellEditor(new PriorityComboBoxEditor());
    }

I would like to implement a new feature: to can update several field using a combobox which is part of my selection. http://imageshack.us/photo/my-images/40/qyks.png/ My probleme begin when i want to select a row wich part in my selection avec select several row, selection is refresh and i have now just one row selected. Is it possible?

Summary : Try to update severals columns with multi selection. Rows contain a column with a combobox. Select severals rows and use a combobox(which is part of selected rows) for update all the rows specific column with the value of combobox.

Regards guys.

1
Hi, appreciate English might not be your first language, but your question is very hard to understand. Could you update/clarify what you're asking? thanks. Protip: Type in your native language and translate using translate.google.com/#fr/en as Google's capabilities are very good these days. - BlackBox
Yes, but doesn't it make more sense to only have 1 combo-box somewhere else in your application instead of duplicating it for each row? that would simplify things for you. - BlackBox
Yes but user can use single line combo box too. I can't change basic design. - MatDev8
First thing : I just want to disable clear selection when i select a row wich part of my multi selection. i search in jTable methode but i don't found... - MatDev8

1 Answers

0
votes

So i change code in changeSelection() methode like this:

if (extend) {
            super.changeSelection(rowIndex, columnIndex, toggle, extend);
            listTest = new ArrayList<Object>();
            for (int e : modelTable.getToolTipsJTable().getSelectedRows()) {
                listTest.add(e);
            }
            isExtend = true;
        } else {
            // super.changeSelection(rowIndex, columnIndex, toggle, extend);
            if (modelTable.getToolTipsJTable().getSelectedRows().length > 1) {
                listTest = new ArrayList<Object>();
                for (int e : modelTable.getToolTipsJTable()
                    .getSelectedRows()) {
                    listTest.add(e);
                }
                isExtend = true;
            }
            if (isExtend) {
                boolean isSame = false;
                for (Object i : listTest) {
                    if (((Integer) i).intValue() == rowIndex) {
                        isSame = true;
                    }
                }
                if (!isSame) {
                    isExtend = false;
                    super.changeSelection(rowIndex, columnIndex, toggle,
                        extend);
                }
            } else {
                super
                    .changeSelection(rowIndex, columnIndex, toggle, extend);
            }
        }

It's just for analyse, forgot cleanliness and performance :D If you need more informations add comment.