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

Cell showing junk chars after mouse click

 
G Kiran Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a screen designed in Swing, for modifying the records in a table in Access database. The screen is working fine. There is only one column that is editable. user types some name in the column 'Player Name'. After pressing tab or clicking on other cell, the text is changing to some junk characters. However, the correct text is stored in the table. If the same screen is opened again, it shows the correct text under the Player name column. If I click on any cell under Player Name column, it again shows junk characters. I have attached a screen shot. The code of the program is given below :
Please look into it and give me a solution. Thanks in advance.


 
G Kiran Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The screen shot was not attached to the previous post.
PlayerEntry.JPG
[Thumbnail for PlayerEntry.JPG]
Screen for Updating Player Names
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am no pro at this, far from it, but it looks as if your last column of the JTable is trying to display the default toString for a byte array rather than display a true String.
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Planet Mars",

Please read your private messages regarding an important announcement.

Thank you,

Rob

pete stein wrote:I am no pro at this, far from it, but it looks as if your last column of the JTable is trying to display the default toString for a byte array rather than display a true String.

Very true indeed. You can remedy this by supplying a custom TableCellRenderer and adding that to the TableColumn, or perhaps making getColumnClass return a different class for that column and using JTable.setDefaultRenderer for that class.
 
G Kiran Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob, I changed my display name :-)

I will acquint myself with the words
TableCellRenderer , getColumnClass and JTable.setDefaultRenderer etc and come back to your help, if needed.
 
G Kiran Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I googled and found some info. Created a new custom cell renderer. Its code is :-



I have set this cell renderer in my previous java file. Still it is NOT working
The full code of this java file where JTable is being used, is given below



Please help me. Thanks in advance.
 
G Kiran Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One observation .........
with the earlier code, only the cell that was modified used to display junk characters. after adding this cell renderer, if I edit text in any row and press tab key, all rows under this player name column are showing junk characters only. Please help me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic