Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Allow user to add new rows in JTable

 
Ali Mardhani
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic