0

I am trying to do some simple application in java. I rendered some CheckBox and ComboBox in jTable. Now i am trying to do work on that item like getting value, Enable-disable combobox. But i am facing some problem.
What i am facing now
1.
I render ComboBox and CheckBox in jTable. I am trying to enable ComboBox when i click on checkbox of respective row. If my checkBox is not enable then it ComboBox should be disable.
I tried it but didn't success.

2
I am trying to click on check box but if i use setSelected then all checkbox are checked but when i am trying to uncheck it, it didn't.
Here is my code for your reference.

    public class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
    public MyComboBoxRenderer(String[] items) {
        super(items);
    }

    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        if (isSelected) {
            setForeground(Color.BLACK);
            super.setBackground(Color.WHITE);
        } else {
            setForeground(Color.BLACK);
            setBackground(Color.WHITE);
        }

        // Select the current value
        setSelectedItem(value);
        return this;
    }
   }

    public class MyComboBoxEditor extends DefaultCellEditor {
    public MyComboBoxEditor(String[] items) {
        super(new JComboBox(items));
     }
   }

.

     public class MyCheckBoxRenderer extends JCheckBox implements TableCellRenderer {
     public MyCheckBoxRenderer(String[] items) {
        super();
       // setSelected(true);
     }

     public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        if (isSelected) {
            setForeground(Color.BLACK);
            super.setBackground(Color.WHITE);
        } else {
            setForeground(Color.BLACK);
            setBackground(Color.WHITE);
        }

       // setSelected(true);
        // Select the current value

        return this;
    }
    }

    public class MyCheckBoxEditor extends DefaultCellEditor {
    public MyCheckBoxEditor() {
        super(new JCheckBox());

} 
}

Give me some hint or reference.
Thanks in Advance.

4