• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying UniCode characters

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It shows a little crown on my Windows 7 system. Can you create a screen shot of what it looks like for you?
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
scr.GIF
screenshot
[Thumbnail for scr.GIF]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm blogging this right now. I totally need to get this article finished and published.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic