Hi All,
Can any one help me in getting the value of a cell after editing it
and no idea of how to add focus to the cell ,
I am using a piece of code as follows
for (int col = 0; col < this.getTable().getColumnCount(); col++) {
String columnName = this.getTable().getColumnName(col);
TableColumn column = tableColumnModel.getColumn(col);
if (columnName.equals("Application")) {
column.setPreferredWidth(150);
} else if (columnName.equals("Warning"))
{
column.setPreferredWidth(60);
}else if (columnName.equals("Critical"))
{
column.setPreferredWidth(60);
for(int row = 0; row < this.getTable().getRowCount(); row++){
column.setCellEditor(new MyTableCellEditor());
}
@SuppressWarnings("serial")
public class MyTableCellEditor extends AbstractCellEditor implements TableCellEditor {
JPanel jpanel = new JPanel(new BorderLayout(5,5));
JTextField tfield = new JTextField();
public MyTableCellEditor()
{
jpanel.add(tfield);
}
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
{
tfield.setText(String.valueOf(value));
return jpanel;
}
public Object getCellEditorValue()
{
//String nucritical = tfield.getText();
//tfield.getText(Integer.parseInt(nucritical));
// int i = Integer.parseInt(nucritical);
//System.out.println(i);
return tfield.getText();
}
}
Please help me in this
Thank you very much