File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JTable Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable Question" Watch "JTable Question" New topic
Author

JTable Question

Nawar Gailani
Ranch Hand

Joined: Feb 08, 2005
Posts: 46
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

Joined: Feb 03, 2006
Posts: 62
Do you mind posting your code so that it I (and anyone else who looks at this post) can see what is going on?


Jerret Halter<br /> <br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.<hr></blockquote>
Nawar Gailani
Ranch Hand

Joined: Feb 08, 2005
Posts: 46
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

Joined: Feb 03, 2006
Posts: 62
are u omiting anything? i do not see any main method
Nawar Gailani
Ranch Hand

Joined: Feb 08, 2005
Posts: 46
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

Joined: Feb 03, 2006
Posts: 62
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

Joined: Feb 08, 2005
Posts: 46
Ok it is solved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable Question
 
Similar Threads
Slumdog Millionaire
Creating an editable table using an array of input tags
Problem with setting the cell values in JTable
cell model and table display
Favourite motivational songs?