Hello guys.
I am doing a swing application wherein I m using a DefaultTableModel.
Here's my code:

DefaultTableModel tab = new  DefaultTableModel(){
         @Override  public boolean isCellEditable(int r, int c){
                        //if(c == 10) {return true;}
                        return false;
                    }
        };
    
     private JTable jt = new JTable(tab);

The JTable will diplay records from database.
I have a form where I am displaying the tabl. I have a 'Delete' button on whose click I want to delete the row selected of the Jtable.
The reason I m using a DefaultTableModel is becoz I want to dynamically add rows to the JTabl depending upon the no. of records in my database table.
So, I cannot find a function using which I can get the row selected..or atleast the cell selected.
How can I do that? Thanks.

Recommended Answers

All 3 Replies

The selection happens in the JTable, not in the underlying model, so you need to look at JTable methods like getSelectedRow() etc.

Thank you guys..the problems solvd..:*

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.