This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Displaying UniCode characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Displaying UniCode characters" Watch "Displaying UniCode characters" New topic
Author

Displaying UniCode characters

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

I'm puzzling on how to have my screen output the actual character given by myChessPiece, rather than a '?'; Do I need to use Graphics2D and draw a string?


Related links
1. Unicode chart helper

Jon
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

The Windows XP console prompt uses a font that does not contain all Unicode characters. There are many characters that it cannot display. If you want to show these characters, you could indeed write a Swing application, making sure that you use a font which contains the characters that you want to display.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

Jesper de Jong wrote:The Windows XP console prompt uses a font that does not contain all Unicode characters. There are many characters that it cannot display. If you want to show these characters, you could indeed write a Swing application, making sure that you use a font which contains the characters that you want to display.


However I think I need to add something on to my JPanel, because on my screen it does not show the chess piece that I am expecting:




Sourced from Core Java Vol I (8th ed).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

It shows a little crown on my Windows 7 system. Can you create a screen shot of what it looks like for you?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

Rob Spoor wrote:It shows a little crown on my Windows 7 system. Can you create a screen shot of what it looks like for you?


Sure here it is



[Thumbnail for scr.GIF]

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'm blogging this right now. I totally need to get this article finished and published.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

You're not setting the font anywhere, so it is most likely still using a font that does not contain the Unicode character you are trying to display, so you get a square instead of the character.

Note that the Graphics object you are using inside the paintComponent method has a setFont() method. Make sure you use a font that contains the characters you want to display. Not all fonts contain all possible Unicode characters - in fact, most fonts contain only a small subset of all available Unicode characters.

Apparently the default font on Rob's Windows 7 system does contain the character, but the font on your Windows XP system does not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying UniCode characters
 
Similar Threads
getting batchupdate exception while inserting recored for second time...
LinkedHashMap - trying to use the method removeEldestEntry
Java mail api
iterate problem in struts2
object required in java script error