Question:
Java special characters GUI?
anonymous
2011-05-01 04:16:31 UTC
I am having problems with special characters: (♥♣♠♦) (\u2663). I am writing a card game and am converting a system.out game to a GUI game. During system.out, the symbols worked, they also worked on the GUI. But after I tried the below code, it no longer works. I wanted to enlarge the font so I applied the font to the panel. Now even when I comment it out, it doesn't show the symbols anymore. I think it was the middle parameter in Font( , 0, ) that caused this. How do I fix this?.. it just shows squares in place of those symbols.


Code:
Font newFont = new Font("name", 0, 20);
panelA.setFont(newFont);
Three answers:
Damien Bell
2011-05-01 04:33:51 UTC
Without seeing the rest of your code I can't be entirely sure that my answer is correct, so you may want to take this with a grain of salt:



The special characters that are used (your ♥♣♠♦ in this case) are all members of the Arial unicode font library. In the event that you are NOT using Arial as your font, these would no longer be available. If you are still using arial, test by doing a System.out.println at the very beginning of your program to see if it still works, if that doesn't work then clearly there is an issue in one of your includes, otherwise check for font face redefinitions.
deonejuan
2011-05-01 06:55:14 UTC
I don't know where you got this:

new Font("name", 0, 20);



Java comes with

Dialog

SansSerif

Serif

Monospaced

DialogInput



You will have to blip your UIManager to get back to the default font of a JLabel. To 'blip' you do the old

try{

UIManager set L & F

catch{}



On Linux, you do have Unicode characters in every situation. On WIndozo cmmd-prompt terminal, you do NOT have Unicode. You do have Unicode when you display java on a web page or a Swing widget even on Windoze.
?
2016-10-19 12:38:18 UTC
Open the report, examine it right into a Java string, use the String replace methods or Java's familiar expressions. Overwrite the unique report. it extremely is the belligerent way. the extra suitable way could be to open the report, examine each line in one at a time, seem for the textual content cloth you opt to swap, if got here across, write out the substitute (you will possibly desire to back the report pointer back to the start of the line.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...