Hey guys. I'm making a project for my university. It consists of Jframes and other JStuff.
I'm having problem with data. The problem is changing them.
I have 2D array of Strings - numbers and words (but the content doesn't matter).
I want to make a JFrame, where you can choose row&column and set new value to one string of the array.
Inputs will be made in JLabels, supposably. But i don't know, how to change them.
I have a method, where you can get data from an array like getData(int row, int column)
- that's easy.
But how to set data?
I also have a JTable, where all the data are shown in the table.
when I change the data, it shows, that method is called, but when i open my JTable again, it is not changed (when i open data Jtable, it's method is recalled, so there isn't problem with that).
I guess that, when the method setData(int r, int c, String new_value)
is called, it changes the value, but when i make the JTable, values are taken from the first initialized array at the beggining).
public void setData(int row, int col, String value) {
pilns[row][col] = value;
}
public String getData(int row, int col) {
String toReturn = pilns[row][col];
return toReturn;
}
code looks sth like that. If you need sth else, write. I really hope smb can help me.
I just registered for this site, because lots of answers for others have helped me too! "this site is a keeper" LOL :D