问题
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