Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable Question

 
Nawar Gailani
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can someone help explain to me (or point to a link) about how can I display permanently the values edited in the cells?
I have a table with three columns:
Song, Rel. Year, Lyrics
Song column is just a String.
Rel. Year is Date.
Lyrics is a link to a specified file that contains the lyrics.
As I want the user to edit the values in the table, I wrote TableModel, CellEditor, and CellRenderer. Whatever I tried, the data entered disappeared when I tab (move) to another cell. I tried this in the CellEditor:

public Object getCellEditorValue() {
return new String(getText());
}

I don't know if this is the reason really. So what I should do to make the changes remained when I move to other cells?

Thanks in advance
 
Jerret Halter
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mind posting your code so that it I (and anyone else who looks at this post) can see what is going on?
 
Nawar Gailani
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jerret,
This is the TableModel:



and this is the CellEditor:



and this is the CellRenderer which i don't know if i need one, but i think
that i need one for the last column:



Hope it is not a mess!
What i want to do is to display an empty row waiting for the user to fill in
the row. In the current state of the code, when the user fill a cell and move to another, the first one reseted to display nothing.
 
Jerret Halter
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are u omiting anything? i do not see any main method
 
Nawar Gailani
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jerret,
The main method is in another file, the AudioForm. I can't post the AudioForm because it is about 3000 lines!
I believe the main method is ok, because i can run the program correctly, and I also assigned the TableModel, CellEditor, and CellRenderer to the AudioTable in the AudioForm correctly. So mostly there is something wrong in one or more of the 3 files i posted.
I will try some ideas and see if they work.
Thanks for your replies.
 
Jerret Halter
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason that I was wanting it was so that I could run the program and use a debugger to find out what you problem is. Please feel free to e-mail me your file with the main method I would be more then happy to work with it.
 
Nawar Gailani
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok it is solved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic