Populate JTable

JTable tbl = new JTable(); DefaultTableModel dtm = new DefaultTableModel(0, 0); // add header of the table String header[] = new String[] { "Word", "Something" }; // add header in table model dtm.setColumnIdentifiers(header); //set model into the table object tbl.setModel(dtm); // add row dynamically into the table //use your custom object for (int count = 1; count <= 30; count++) { dtm.addRow(new Object[] { "word", "something"}); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.