• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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!!!
 
I'm still in control here. LOOK at this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic