I am using swing to create a table in Java. There are 6 fields of data that will be printed in an excel-like table. This part is not the problem. The problem is that the number of rows will vary. I was able to write code to store what would need to be printed within "new Object [][] { " in a String variable called "tabObjLS" which is exactly exactly like "{null, null, null...}..." including the curly braces, commas, etc so that if you were to use system.out.println(tabObjLS); the program would print this:
{data1a, data2a, data3a, data4a, data5a, data6a},
{data1b, data2b, data3b, data4b, data5b, data6b},
{data1c, data2c, data3c, data4c, data5a, data6c}
The content of tabObjLS is exactly what the code needs to look like where the comments are located with {null, null, null,...}... seen in the code below. My question is how to retrieve the string from tabObjLS and convert it so that it is seen as code in the editor upon compiling and running the program.
jTable2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
// {null, null, null, null, null, null, null},
// {null, null, null, null, null, null, null},
// {null, null, null, null, null, null, null},
// {null, null, null, null, null, null, null},
// ...
// ...
},
new String [] {
"Student Name", "ID", "Book Title", "Date Out", "Due Date", "Due"
}
));
jScrollPane2.setViewportView(jTable2);
Aucun commentaire:
Enregistrer un commentaire