How to change column headers localization of custom table model

94 views Asked by At

I have a table model that extends AbstractTableModel and I created a method to change header like this

public void ChangeHeader(Locale l){
        ResourceBundle r = ResourceBundle.getBundle("newpackage/Bundle", l);
        this.Column[1] = r.getString("TableModel.header1.text");
        this.Column[2] = r.getString("TableModel.header2.text");
        this.Column[3] = r.getString("TableModel.header3.text");
\\      System.out.println(r.getString("TableModel.header1.text"));
    }

I have few buttons to change header but since they're all the same so I only show one and here is my method ActionPerformed in JFrame,

private void jButtonVNActionPerformed(java.awt.event.ActionEvent evt) {                                          
        Locale l = new Locale("vi", "VN");
        ResourceBundle r = ResourceBundle.getBundle("newpackage/Bundle", l);
        tableModel.ChangeHeader(l);
        jTable1.updateUI();
    }

The problem is, it does print out the header's name but It doesn't change in table

1

There are 1 answers

0
Doan Van Thang On

nvm I found solution, don't need to create method in table model, just need to getTableHeader() then setHeaderValue() in ActionPerformed method . Dumb me