JFormDesigner ignoring the encoding

115 Views Asked by At

JFormDesigner doesn't display some languages properly, see attached screen shot, particularly Russian and Hebrew. The only reason Chinese is shown ok is because I've converted it into ASCII. All files are encoded in UTF8 but JFormDesigner seems to ignore that, I've tried to enforce -Dfile.encoding=utf-8 property in JFormDesigner.vmoptions file, but to no avail.. Tried in several versions including the latest one, the support is no reachable. Stuck!

Anybody seen this problem?

enter image description here

1

There are 1 best solutions below

0
vahid rajabi On

I had this problem too . the result is you make some change in your initComponents() (for labels or buttons or other element at defining)

1- put all the text you want to show in your UI at a resource bundle (you can make it when you want to create a new jformdesigner form , at localization , check the store string in resource...

2- find the element that you want to have UTF-8 text for example i want to make a lable with UTF-8 text

ResourceBundle bundle = ResourceBundle.getBundle(YOUR_BUNDLE);           

then get the string

 String str = bundle.getString(TEXT_NAME_IN_BUNDLE);

now change it to UTF-8

 label.setText(new String(str.getBytes("ISO-8859-1"), "UTF-8"));

be careful that you need a try()/catch block

any other strings can be set with this method