• 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

Allow user to add new rows in JTable

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi There,

I wish to allow user to add new rows to JTable. I can not find any documentation to achieve that. Here is part of my code:

// create a table
String[] columnNames = {"Age", "Blood Sugar"};
Object [][] data = {{new Integer(50), new Float(10.11) }};
TableModel myData = new DefaultTableModel(data,columnNames);
JTable table = new JTable(myData);
JScrollPane scrollPane = new JScrollPane(table);

// add table to the container
frame.add(table, BorderLayout.CENTER);

// show table
frame.setVisible(true);
 
reply
    Bookmark Topic Watch Topic
  • New Topic