public class ReadOnlyTableModel
extends java.lang.Object
implements javax.swing.table.TableModel
TableModel
decorates an existing table model making it read only by overriding the isCellEditable
method to return true. You can apply this model to an existing table where you want the make the data non
editable form the UI.
table.setModel(new ReadOnlyTableModel(table.getModel());
Constructor and Description |
---|
ReadOnlyTableModel(javax.swing.table.TableModel model) |
Modifier and Type | Method and Description |
---|---|
void |
addTableModelListener(javax.swing.event.TableModelListener l) |
java.lang.Class<?> |
getColumnClass(int columnIndex) |
int |
getColumnCount() |
java.lang.String |
getColumnName(int columnIndex) |
int |
getRowCount() |
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex) |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Always returns false
|
void |
removeTableModelListener(javax.swing.event.TableModelListener l) |
void |
setValueAt(java.lang.Object aValue,
int rowIndex,
int columnIndex) |
public int getRowCount()
getRowCount
in interface javax.swing.table.TableModel
public int getColumnCount()
getColumnCount
in interface javax.swing.table.TableModel
public java.lang.String getColumnName(int columnIndex)
getColumnName
in interface javax.swing.table.TableModel
public java.lang.Class<?> getColumnClass(int columnIndex)
getColumnClass
in interface javax.swing.table.TableModel
public boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface javax.swing.table.TableModel
rowIndex
- columnIndex
- public java.lang.Object getValueAt(int rowIndex, int columnIndex)
getValueAt
in interface javax.swing.table.TableModel
public void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
setValueAt
in interface javax.swing.table.TableModel
public void addTableModelListener(javax.swing.event.TableModelListener l)
addTableModelListener
in interface javax.swing.table.TableModel
public void removeTableModelListener(javax.swing.event.TableModelListener l)
removeTableModelListener
in interface javax.swing.table.TableModel