Accented characters in JTextField

会有一股神秘感。 提交于 2020-01-17 03:30:30

问题


I'm making an application where I use JTextField to connect to something (in this case, a database), but when I try to do so with the good login/password, it doesn't work, because some special characters become wrong characters.

example: ç become a Greek letter, é become ù, etc . . .

I think it's a charset problem, but I couldn't find how to fix it.

My code looks like this:

JTextField login = new JTextField();
JTextField passw = new JTextField();

JButton connect = new JButton("Connect");
connect.addActionListener( new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            connect(login.getText(), passw.getText());
        }
    });

Where connect() is my method to connect to the database. When I print special characters from the JTextField.getText() function, it's all messed up.

I'm running on a Windows 7 PC

来源:https://stackoverflow.com/questions/24017029/accented-characters-in-jtextfield

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!