-1

I am having trouble displaying UTF-8 characters in JButtons on Windows. I have tried running this on a Linux OS and it works.

There are have been no errors. However, the characters are displayed as "☐". I would like them to be displayed as "नमस्ते".

import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class a extends JFrame{
    public static void main(String[] args){
        JFrame frame = new JFrame();
        frame.setSize(100,100);
        frame.setVisible(true);
        frame.add(new JButton("नमस्ते"), BorderLayout.NORTH);
        frame.add(new JLabel("नमस्ते"));
    
        frame.setSize(300,300);
        frame.setLocationRelativeTo(null);
    }
}

Update: I was unable to solve this issue by using a Font that supports UTF-8. However, I was able to solve this problem by installing Hindi language support in windows settings.

PS: I do not have enough reputation to answer my own question, but I will do so when I can.

Shorent
  • 1
  • 2

0 Answers0