Class JTableForDB

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public class JTableForDB
extends AlternateRowColoursJTable
This class extends a JTable with specific cellrenderers for fields, retrieved from DB.
Author:
Lennart Martens
See Also:
Serialized Form
  • Constructor Details

    • JTableForDB

      public JTableForDB()
      Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model.
      See Also:
      JTable.createDefaultDataModel(), JTable.createDefaultColumnModel(), JTable.createDefaultSelectionModel()
    • JTableForDB

      public JTableForDB​(int numRows, int numColumns)
      Constructs a JTable with numRows and numColumns of empty cells using DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.
      Parameters:
      numRows - the number of rows the table holds
      numColumns - the number of columns the table holds
      See Also:
      DefaultTableModel
    • JTableForDB

      public JTableForDB​(TableModel dm, TableColumnModel cm)
      Constructs a JTable that is initialized with dm as the data model, cm as the column model, and a default selection model.
      Parameters:
      dm - the data model for the table
      cm - the column model for the table
      See Also:
      JTable.createDefaultSelectionModel()
    • JTableForDB

      public JTableForDB​(TableModel dm)
      Constructs a JTable that is initialized with dm as the data model, a default column model, and a default selection model.
      Parameters:
      dm - the data model for the table
      See Also:
      JTable.createDefaultColumnModel(), JTable.createDefaultSelectionModel()
    • JTableForDB

      public JTableForDB​(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
      Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model. If any of the parameters are null this method will initialize the table with the corresponding default model. The autoCreateColumnsFromModel flag is set to false if cm is non-null, otherwise it is set to true and the column model is populated with suitable TableColumns for the columns in dm.
      Parameters:
      dm - the data model for the table
      cm - the column model for the table
      sm - the row selection model for the table
      See Also:
      JTable.createDefaultDataModel(), JTable.createDefaultColumnModel(), JTable.createDefaultSelectionModel()
    • JTableForDB

      public JTableForDB​(Vector rowData, Vector columnNames)
      Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. The Vectors contained in rowData should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:

      ((Vector)rowData.elementAt(1)).elementAt(5);


      Each row must contain a value for each column or an exception will be raised.
      Parameters:
      rowData - the data for the new table
      columnNames - names of each column
    • JTableForDB

      public JTableForDB​(Object[][] rowData, Object[] columnNames)
      Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames. rowData is an array of rows, so the value of the cell at row 1, column 5 can be obtained with the following code:

       rowData[1][5]; 


      All rows must be of the same length as columnNames.
      Parameters:
      rowData - the data for the new table
      columnNames - names of each column
  • Method Details

    • setDateTimeFormat

      public void setDateTimeFormat​(String aFormat)
      This method allows the setting of the date /time format.
      Parameters:
      aFormat - String with the datetimeformat.
    • setModel

      public void setModel​(TableModel aModel, boolean aSortable)
      This method allows you to specify a tablemodel and a boolean which indicates whether or not the table should be sortable by clicking the column headers.
      Parameters:
      aModel - TableModel with the data.
      aSortable - boolean that indicates whether the table should be sortable.
    • setModel

      public void setModel​(TableModel aModel)
      Sets a TableModel for the table and defaults it to being sortable.
      Overrides:
      setModel in class JTable
      Parameters:
      aModel - TableModel with the data for this table.
    • finalize

      protected void finalize() throws Throwable
      Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

      The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

      The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

      The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

      After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

      The finalize method is never invoked more than once by a Java virtual machine for any given object.

      Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

      Overrides:
      finalize in class Object
      Throws:
      Throwable - the Exception raised by this method