This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Zero to AI - A non-technical, hype-free guide to prospering in the AI era and have Nicolò Valigi and Gianluca Mauro on-line!
See this thread for details.
Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Displaying UniCode characters

 
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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
Eclipse IDE Chrome
  • 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).
 
Sheriff
Posts: 22015
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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
Eclipse IDE Chrome
  • 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
[Thumbnail for scr.GIF]
screenshot
 
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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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.
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic