How to add ComboBox as a cell editor in table of ToolWindow (JBTable)

public class Example extends JDialog {

    private DefaultTableModel dtm;
    private
JBTable tbProperty;
    private
JBScrollPane scrPropertyTable;
    private
ComboBox cmb1;

    public
HttpClientAdvance(Window owner) {
        super(owner);
        
createUIComponent();
    
}

    private void createUIComponent(){
        tbProperty = new JBTable(){
            @Override
            public
TableCellEditor getCellEditor(int row, int column) {
                Object value = super.getValueAt(row, column);
                if
(value != null) {
                    if(value instanceof ComboBox) {
                        return new ComboBoxCellEditor(cmb1);
                    
}
                    if(row == 0 && column == 1) {
                        return new DefaultCellEditor(cmb1);
                    
}
                    return getDefaultEditor(value.getClass());
                
}
                return super.getCellEditor(row, column);
            
}
        };
        scrPropertyTable
= new JBScrollPane(tbProperty);
        cmb1
= new ComboBox(new Object[]{"1.1", "1.0"});

        dtm
= new DefaultTableModel(null, new String[]{"Property","Value"}){
            @Override
            public boolean isCellEditable
(int row, int column) {
                return column == 1;
            
}

        };

        cmb1
.setSelectedIndex(0);
        tbProperty
.setModel(dtm);
        dtm
.addRow(new Object[]{"Example", "1.0"});
        dtm
.addRow(new Object[]{"Example", cmb1});

        tbProperty
.setCellEditor(new ComboBoxTableCellEditor());
        
ComboBoxModel<String> model =cmb1.getModel();
try
        
add(scrPropertyTable);
        
pack();

    
}

    public static void main(String[] args) {
        new HttpClientAdvance(null).setVisible(true);

}


I try to implement this using above example. but it is not successful. I found ComboBoxCellEditor Class in intellij idea lib. How to use this to solve my problem?? You have example source please send me.
I want to implement property table like idea provide GUI form property table. (following attach property table image)

prttable.png



Attachment(s):
prttable.png
0

Please sign in to leave a comment.