wnchui
asked on
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().g etColumn(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(n ew DefaultCellEditor(comboBox ));
Then, how to add different items to different comboBox in JTable.
I use the code below to add JComboBox to JTable.
testColumn = JTable1.getColumnModel().g
JComboBox comboBox = new JComboBox();
comboBox.addItem("1");
comboBox.addItem("2");
comboBox.addItem("3");
comboBox.addItem("4");
comboBox.addItem("5");
comboBox.addItem("None");
testColumn.setCellEditor(n
Then, how to add different items to different comboBox in JTable.
Hi,
Use this method inthe interface TableCellEditor
public Component getTableCellEditorComponen t(JTable table,
Object value,
boolean isSelected,
int row,
int column)
Use the component returned to disable it..
Try it...
Use this method inthe interface TableCellEditor
public Component getTableCellEditorComponen
Object value,
boolean isSelected,
int row,
int column)
Use the component returned to disable it..
Try it...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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...
visit this,i think this will solve ur problem
http://forum.java.sun.com/forum?13@40.YLRza9Udkwq^0@.eeec9e9/0
good luck ...
mb...
ASKER
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?
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?
ASKER
how can I disable particular cells in run time?
use the property isCellEditable();
mb...