I want to make 25 JTables. I generate the table names by doing:
for(int i=0; i < 26; i++)
{
TableNames[i] = "Table" + i + "";
...
How can I go about using these String names in the array as the new JTable names? i.e.
TableNames[i] = new JTable(model){ ...
Instead of an array, consider using a
List<JTable>
orList<TableModel>
. Pass the name to the table's constructor or factory method. The example below uses theComponent
's name, but aJComponent
's client property may be more versatile.Update: The revised Java 8 example below illustrates how to add new tables dynamically.
put inside the for loop i agree previous statement make error try this