-2

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);
copy14
  • 3
  • 3
  • 2
    How do you want to display it. `System.out.println()` or somehow else? You mention a `label` is that a `JLabel`? – Shavk with a Hoon Jul 07 '22 at 16:41
  • Assuming this is either a `Label` or a `JLabel`, what fonts did you try? – David Conrad Jul 07 '22 at 16:49
  • 2
    maybe you should include the code... it works with `JOptionPane.showMessageDialog(null, new JLabel("✤ \u2724"))` see the [screenshot](https://i.stack.imgur.com/C5Byy.png) (first symbol copied directly from question - using default font: `Dialog, bold, 12`) – user16320675 Jul 07 '22 at 17:12
  • `System.out.println ( "✤" + " " + java.time.Instant.now() ) ;` See that code [run live at IdeOne.com](https://ideone.com/QG1Mn0). – Basil Bourque Jul 07 '22 at 19:40
  • How are you running it? Terminal? IDE? Remote system? I ran `System.out.println("✤")` locally in IntelliJ and it printed this output: `✤`. No issues. – Kaan Jul 07 '22 at 21:26
  • 1
    Update your question: [1] Show your code. [2] Name the fonts you have tried. [3] Explain what approach you are using to render the symbol. You should provide enough information so that others can attempt to replicate your approach. Without those crucial details your question is unanswerable, and likely to be closed. – skomisa Jul 08 '22 at 05:56

1 Answers1

1

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.

  • 1
    Can't be the 'saved in an encoding' issue, given that they 'even tried with the unicode escape'. Font just doesn't have the character. All fonts they tried. @copy14, if you're confident the font has it, paste actual code. – rzwitserloot Jul 07 '22 at 17:43