Fabycor
Fabycor

Reputation: 13

Header JTable i18n in Netbeans

I applied to all components i18n of my forms, but I couldn`t internationalize JTable headers. And I can not edit it because it's code generated by netbeans. Any help?

thanks

Upvotes: 1

Views: 853

Answers (1)

Costis Aivalis
Costis Aivalis

Reputation: 13728

You can edit code generated by Netbeans with any editor you like. That is if you do not plan to use the Netbeans GUI designer anymore.

Probably the JTable headers of your application are hardwired in one language. You should change that and add them to your locale property files.

You can do it like this:

public class TableModel extends AbstractTableModel {
    private String[] headers;
    public TableModel() {
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("internationals/Bundle"); // NOI18N
        headers = new String[3];
        headers[0] = bundle.getString("TableModel.header1.text");
        headers[1] = bundle.getString("TableModel.header2.text");
        headers[2] = bundle.getString("TableModel.header3.text");
    }
    ....
    @Override
    public String getColumnName(int i) {
        return headers[i];
    }

and prepare your locale property file like this:

enter image description here

Upvotes: 2

Related Questions