[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1715
  • Last Modified:

Disable a particular cell in JTable

How to disable a particular cell in JTable.
I use the code below to add JComboBox to JTable.
          testColumn = JTable1.getColumnModel().getColumn(1);
          JComboBox comboBox = new JComboBox();
        comboBox.addItem("1");
        comboBox.addItem("2");
        comboBox.addItem("3");
        comboBox.addItem("4");
        comboBox.addItem("5");
        comboBox.addItem("None");
        testColumn.setCellEditor(new DefaultCellEditor(comboBox));

Then, how to add different items to different comboBox in JTable.
0
wnchui
Asked:
wnchui
1 Solution
 
expertmbCommented:
hi,

use   the property isCellEditable();

mb...
0
 
vivexpCommented:
Hi,

Use this method inthe interface  TableCellEditor

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)


Use the component returned to disable it..

Try it...
0
 
shaveriCommented:
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
expertmbCommented:
hi,
 visit this,i think this will solve ur problem

http://forum.java.sun.com/forum?13@40.YLRza9Udkwq^0@.eeec9e9/0

good luck ...

mb...
0
 
wnchuiAuthor Commented:
I try to use this method:

class UneditableJTable extends JTable
{
    public boolean isCellEditable(int row, int column)  
    {
        return false;
    }
}

and then,

UneditableJTable JTable1 = new UneditableJTable();

and JTable1.isCellEditable(1, 1);

but, it will disable all the cell in JTable, how can I disable particular cell?
0
 
wnchuiAuthor Commented:
how can I disable particular cells in run time?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now