hicosim.components.frontend.tablemodels
Class CustomAbstractTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by hicosim.components.frontend.tablemodels.CustomAbstractTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
CustomAbstractTableModelWithEditiableCells

public class CustomAbstractTableModel
extends javax.swing.table.AbstractTableModel

This class extends the super class AbstractTableModel and provides methods to hide and show rows and columns and also to add and remove rows and columns.

Author:
Daniel Obermueller 28th May 2009
See Also:
Serialized Form

Constructor Summary
CustomAbstractTableModel()
           
CustomAbstractTableModel(java.util.Vector<java.util.Vector<java.lang.Object>> data)
           
 
Method Summary
 void addColumn()
          This method adds a column at the end of the JTable.
 void addRow()
          This method adds a row at the end of the JTable.
 int getAmountOfColumns()
          This method returns the amount of columns as an Integer-Object.
 int getAmountOfRows()
          This method returns the amount of rows as an Integer-Object.
 int getColumnCount()
          This method returns the amount of visible columns as an Integer-Object.
 int getRowCount()
          This method returns the amount of visible rows as an Integer-Object.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          This method returns a value, which is an Object, located at the passed indexes int "rowIndex" and int "columnIndex".
 void hideColumn(int column)
          This method hides a column, which is specified by the passed Integer-Object "column".
 void hideRow(int row)
          This method hides a row, which is specified by the passed Integer-Object "row".
 void removeLastColumn()
          This method removes the last column of the JTable.
 void removeLastRow()
          This method removes the last row of the JTable.
 void setData(java.util.Vector<java.util.Vector<java.lang.Object>> data)
          This method is used to set the data vector of the JTable, which is using this class.
 void setJTableSize(int rows, int columns)
          This method sets the size of the JTable.
 void setRow(java.util.Vector<java.lang.Object> rowData, int row)
          This method sets the content of the passed row, by using the Vector "rowData".
 void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
          This method sets the content of the passed cell, specified by the two Integer-Objects "rowIndex" and "columnIndex", using the Object value.
 void showColumn(int column)
          This method shows a column, which is specified by the passed Integer-Object "column".
 void showRow(int row)
          This method shows a row, which is specified by the passed Integer-Object "row".
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomAbstractTableModel

public CustomAbstractTableModel(java.util.Vector<java.util.Vector<java.lang.Object>> data)
Parameters:
Vector - > data

CustomAbstractTableModel

public CustomAbstractTableModel()
Method Detail

setJTableSize

public void setJTableSize(int rows,
                          int columns)
This method sets the size of the JTable.

Parameters:
int - rows
int - columns

getRowCount

public int getRowCount()
This method returns the amount of visible rows as an Integer-Object. This method had to be overwritten in order to implement the hide and show methods.

Returns:
int

getColumnCount

public int getColumnCount()
This method returns the amount of visible columns as an Integer-Object. This method had to be overwritten in order to implement the hide and show methods.

Returns:
int

getAmountOfRows

public int getAmountOfRows()
This method returns the amount of rows as an Integer-Object.

Returns:
int

getAmountOfColumns

public int getAmountOfColumns()
This method returns the amount of columns as an Integer-Object.

Returns:
int

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
This method returns a value, which is an Object, located at the passed indexes int "rowIndex" and int "columnIndex".

Parameters:
int - rowIndex
int - columnIndex
Returns:
Object

setData

public void setData(java.util.Vector<java.util.Vector<java.lang.Object>> data)
This method is used to set the data vector of the JTable, which is using this class.

Parameters:
Vector - > data

addColumn

public void addColumn()
This method adds a column at the end of the JTable.


removeLastColumn

public void removeLastColumn()
This method removes the last column of the JTable.


addRow

public void addRow()
This method adds a row at the end of the JTable.


removeLastRow

public void removeLastRow()
This method removes the last row of the JTable.


setRow

public void setRow(java.util.Vector<java.lang.Object> rowData,
                   int row)
This method sets the content of the passed row, by using the Vector "rowData".

Parameters:
Vector - rowData
int - row

setValueAt

public void setValueAt(java.lang.Object value,
                       int rowIndex,
                       int columnIndex)
This method sets the content of the passed cell, specified by the two Integer-Objects "rowIndex" and "columnIndex", using the Object value.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
Object - value
int - rowIndex
int - columnIndex

hideRow

public void hideRow(int row)
This method hides a row, which is specified by the passed Integer-Object "row".

Parameters:
int - row

showRow

public void showRow(int row)
This method shows a row, which is specified by the passed Integer-Object "row".

Parameters:
int - row

hideColumn

public void hideColumn(int column)
This method hides a column, which is specified by the passed Integer-Object "column".

Parameters:
int - column

showColumn

public void showColumn(int column)
This method shows a column, which is specified by the passed Integer-Object "column".

Parameters:
int - column