• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Cell showing junk chars after mouse click

 
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
 
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.
 
Sheriff
Posts: 21865
105
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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.
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!