Skip to content

How to display X-Bar statistics symbol in Java Swing label?

What’s the best way to insert statistics symbols in a JLabel‘s text? For example, the x-bar? I tried assigning the text field the following with no success:




Html codes will not work in Java. However, you can use the unicode escape in Java Strings.

For example:

JLabel label = new JLabel(new String("u0304"));

Also, here is a cool website for taking Unicode text and turning it into Java String leterals.

User contributions licensed under: CC BY-SA
7 People found this is helpful