Ok basically what I am doing is i have a jtable in which users can enter their information into the table, I then want to be able to save it into a text file. The problem I am running into however is along the lines of this.
private static String dataValues[][];
I want to be able to declare dataValues like this so I can accesses it in every method so I can add rows to my jtable like this:
dataValues = {{number, owner, txtDate"}};
tableModel.addRow(dataValues);
however I get an error on the dataValues saying that “Array constants can only be used in initializers.” And i dont really understand what that means.
if I declare the variable like this in the actual method it works.
String[][] dataValues = {{number, owner, txtDate}};
But I need to be able to access it anywhere in the program so declaring it like that will not help me.
Thanks for the help in advance.
The JTable represents the data internally with a TableModel. What the JTable does in the constructor is convert the initial array into the TableModel. What you need to do is think in terms of TableModels as described in the following link: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#data