All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface multilizer.MTableModel

public interface MTableModel
The interface that extends TableModel such way that the model can be translated.

The javax.swing.table.TableModel lacks a method to set column name. MTableModel adds the method to the interface. Use MTableModel instead of TableModel, and add multilizer.SwingModule to your application if you want to translate the column headers of the JTable.

An example:

 class MyTableModel extends AbstractTableModel implements MTableModel
 {
   final String[] columnNames =
   {
     "First Name", //ivlm
     "Last Name", //ivlm
     "Sport", //ivlm
     "Est. Years Experience" //ivlm
   };
   final String[][] data =
   {
     {"Mary", "Campione", "Snowboarding", "5"},
     {"Alison", "Huml", "Rowing", "3"},
     {"Kathy", "Walrath", "Chasing toddlers", "2"},
     {"Mark", "Andrews", "Speed reading", "20"},
     {"Angela", "Lih", "Teaching high school", "4"}
   };
   public int getColumnCount()
   {
     return columnNames.length;
   }
   public int getRowCount()
   {
     return data.length;
   }
   public String getColumnName(int col)
   {
     return columnNames[col];
   }
   public void setColumnName(String string, int col)
   {
     columnNames[col] = string;
     fireTableStructureChanged();
   }
   public Object getValueAt(int row, int col)
   {
     return data[row][col];
   }
 };
 

Multilizer does not translate the data cells of the JTable automatically. If you want to translate the data cell write your own code and use the Dictionary.translate method.

See Also:
SwingModule

Method Index

 o setColumnName(String, int)
Sets the name of the column at columnIndex.

Methods

 o setColumnName
 public abstract void setColumnName(String string,
                                    int columnIndex)
Sets the name of the column at columnIndex. This is used to set the table's column header name. Note, this name does not need to be unique. Two columns on a table can have the same name.

Parameters:
string - the new value of the column name
columnIndex - the index of column

All Packages  Class Hierarchy  This Package  Previous  Next  Index