Juniorr 0 Newbie Poster

Hi, I am trying to add rows to different tables. I have found this code on the web. But this is only for one JTable. I have three tables in one JFrame. How will I modify this code to three different tables. Thanks for your help.

firstTable = new JTable(Liste.first, Liste.headingsFirst);
secondTable = new JTable(Liste.second, Liste.headingsSecond);
thirdTable = new JTable(Liste.third, Liste.headingsThird);
DefaultTableModel model = new DefaultTableModel();
JTable table = new JTable(model);

// Create a couple of columns
model.addColumn("Col1");
model.addColumn("Col2");

// Append a row
model.addRow(new Object[]{"v1", "v2"});
// there are now 2 rows with 2 columns

// Append a row with fewer values than columns.
// The left-most fields in the new row are populated
// with the supplied values (left-to-right) and fields
// without values are set to null.
model.addRow(new Object[]{"v1"});
// there are now 3 rows with 2 columns

// Append a row with more values than columns.
// The extra values are ignored.
model.addRow(new Object[]{"v1", "v2", "v3"});
// there are now 4 rows with 2 columns
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.