Search code examples
javaunicodefontssymbolsappearance

How can I display a symbol in java?


I want to display this symbol: ✤

I want to appear this on a label. I tried to just paste to the code, and I tried with the Unicode (\u2724) but it shows just a square. I tried other fonts too.

Image of the square:

enter image description here

Edit:

String luck = "\u2724"; \\I tried to use the ✤ symbol too
JLabel lblLuck = new JLabel(luck);
lblLuck.setVerticalAlignment(SwingConstants.TOP);
lblLuck.setFont(new Font("Tahoma", Font.PLAIN, 30));
panel1.add(lblLuck, BorderLayout.CENTER);

Solution

  • Check that the font you are using can display this character. However, sometimes the problem is just that the code in the java file is saved in an encoding other than unicode. Make sure that the code file encoding is unicode.