• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Add an editable row to an non editable JTable

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
shansi raj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael..It works great!!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic