aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Cell showing junk chars after mouse click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Cell showing junk chars after mouse click" Watch "Cell showing junk chars after mouse click" New topic
Author

Cell showing junk chars after mouse click

G Kiran Kumar
Greenhorn

Joined: Apr 12, 2009
Posts: 14
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

Joined: Apr 12, 2009
Posts: 14
The screen shot was not attached to the previous post.



[Thumbnail for PlayerEntry.JPG]

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
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

Joined: Oct 27, 2005
Posts: 19783
    
  20

"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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
G Kiran Kumar
Greenhorn

Joined: Apr 12, 2009
Posts: 14
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

Joined: Apr 12, 2009
Posts: 14
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

Joined: Apr 12, 2009
Posts: 14
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cell showing junk chars after mouse click