wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Add an editable row to an non editable JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Add an editable row to an non editable JTable" Watch "Add an editable row to an non editable JTable" New topic
Author

Add an editable row to an non editable JTable

shansi raj
Greenhorn

Joined: Jul 05, 2006
Posts: 25
Any one knows how to add/insert an editable row to a non editable JTable?
My table populates data from a file and in order to add a new value i want an editable row added to the last in the JTable.
Can anyone help me out?

Thanks
Nick Meverden
Ranch Hand

Joined: Jul 03, 2006
Posts: 59
Are you saying setEnabled(false) has been set on the JTable?

if you want to add an extra line at the end of a JTable for input here is a code example:

String[] columns = {"Column One", "Column Two"};
String[][] data = {{"name", "1"}, {"name", "2"}, {"input row",""}};
javax.swing.table.TableModel model = new javax.swing.table.DefaultTableModel(data, columns);

model.setValueAt("YOUR INPUT VALUE", model.getRowCount() - 1, 1);

javax.swing.JTable table = new javax.swing.JTable(model);
shansi raj
Greenhorn

Joined: Jul 05, 2006
Posts: 25
Hi Nick,
Thanx for ur suggestion.Im not talking about setEnabled. The table is basically a non editable table,but the last row of the table should always be editable.

Any idea?

Thanks
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
shansi raj
Greenhorn

Joined: Jul 05, 2006
Posts: 25
Thanks Michael..It works great!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Add an editable row to an non editable JTable