Announcement Announcement Module
Collapse
No announcement yet.
AbstractObjectTable Spring Rich Client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AbstractObjectTable Spring Rich Client

    Hello,
    I am using an AbstractObjectTable to build a table and I would like to know how to make a column editable. I want to change the value of a column when I double click on it. Moreover, in another column I would like the user to be able to write directly on it after double clicking.

    Code:
     @Override
       protected void onDoubleClick(){
            int row = getTable().getSelectedRow();
            int col = getTable().getSelectedColumn();
            Object value = getTable().getValueAt(row, col);
            if(col == 1){ 
                if(value.equals("F")){
                    getTable().setValueAt("B", row, col);
                }
                else{
                    getTable().setValueAt("F", row, col);
                }
            }
        }
    This code produces the error: Unexpected setValue() on read-only table. Thanks in advance.

  • #2
    RE: AbstractObjectTable Spring Rich Client

    I sorted it out. I have a table with two rows and I was using a GlazedTableModel. Basically what I had to do is to override the isEditable method. With the code below first column will be editable.

    Code:
    public class Table extends AbstractObjectTable {
    
    .....
    
     protected void configureTable(JTable table) {
            GlazedTableModel m = new GlazedTableModel(getBaseEventList(), getColumnPropertyNames(), getModelId()) {
                protected boolean isEditable(Object row, int column) {
                    if(column == 0){
                        return true;
                    }
                    return false;
                }
            };
    
            table.setModel(m);
    
    }
    Last edited by rvelaz; Aug 25th, 2010, 07:37 AM.

    Comment

    Working...
    X