Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

JTable Question

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok it is solved.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic