Class InputTablePane

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class InputTablePane extends JPanel
Table pane for inputing data. This class creates a JPanel containing a JTable plus some controls. The class InputTablePane.ColSpec specifies each column in the table, indicating a title, how the cells in the column are rendered, and how the cells in the column are edited (a null editor indicates that the column is a read-only column).

There are methods for determining the number of rows and columns in the table and for obtaining the values at any given cell, and to create dialog boxes containing this panel or a new instance of this panel.

The table model for this panel's table is initialized by providing a Vector whose type is Vector<Vector<Object>>, with the Vector<Object> representing the rows.

See Also:
  • Field Details

  • Constructor Details

    • InputTablePane

      public InputTablePane(InputTablePane.ColSpec[] colspec, int nrows, boolean canAdd, boolean canDel, boolean canMove)
      Constructor.
      Parameters:
      colspec - an array (one entry per column in column order) specifying a column
      nrows - the number of rows
      canAdd - true if rows can be added to the table; false otherwise
      canDel - true if rows can be deleted from the table; false otherwise
      canMove - true if rows can be moved up or down in the table; false otherwise
    • InputTablePane

      public InputTablePane(InputTablePane.ColSpec[] colspec, Vector<Vector<Object>> rows, boolean canAdd, boolean canDel, boolean canMove)
      Constructor based on explicitly provided rows.
      Parameters:
      colspec - an array (one entry per column in column order) specifying a column
      rows - the table's rows as a Vector of rows, where each row contains a vector whose elements fit the specification provided by the first argument (colspec)
      canAdd - true if rows can be added to the table; false otherwise
      canDel - true if rows can be deleted from the table; false otherwise
      canMove - true if rows can be moved up or down in the table; false otherwise
    • InputTablePane

      public InputTablePane(InputTablePane.ColSpec[] colspec, int nrows, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove)
      Constructor with explicitly provided rows, possibly followed by blank rows.
      Parameters:
      colspec - an array (one entry per column in column order) specifying a column
      initialRows - the table's initial rows as a Vector of rows, where each row contains a vector whose elements fit the specification provided by the first argument (colspec)
      nrows - the number of rows
      canAdd - true if rows can be added to the table; false otherwise
      canDel - true if rows can be deleted from the table; false otherwise
      canMove - true if rows can be moved up or down in the table; false otherwise
  • Method Details

    • getRowCount

      public int getRowCount()
      Get the number of rows in the table.
      Returns:
      the number of rows
    • getColumnCount

      public int getColumnCount()
      Get the number of columns in the table.
      Returns:
      the number of tables.
    • getValueAt

      public Object getValueAt(int rowIndex, int columnIndex)
      Get the value of a table cell for this table.
      Parameters:
      rowIndex - the row index (starting at 0)
      columnIndex - the column index (starting at 0)
      Returns:
      the value for the specified row and column
    • stopCellEditing

      public void stopCellEditing()
      Stop editing a cell.
    • showDialog

      public static InputTablePane showDialog(Component parent, String title, InputTablePane.ColSpec[] colspec, int nrows, boolean canAdd, boolean canDel, boolean canMove)
      Create a new InputTablePane inside a dialog.
      Parameters:
      parent - the component on which to center the dialog
      title - the title of the dialog
      colspec - the column specification for the table
      nrows - the number of rows in the table
      canAdd - true if rows can be added to the table; false otherwise
      canDel - true if rows can be deleted from the table; false otherwise
      canMove - true if rows can be moved up or down in the table; false otherwise
    • showDialog

      public static InputTablePane showDialog(Component parent, String title, InputTablePane.ColSpec[] colspec, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove)
      Create a new InputTablePane, initializing some rows, placing the table inside a dialog.
      Parameters:
      parent - the component on which to center the dialog
      title - the title of the dialog
      colspec - the column specification for the table
      initialRows - the rows to initially add to the table, which determines the initial number of rows in the table.
      canAdd - true if rows can be added to the table; false otherwise
      canDel - true if rows can be deleted from the table; false otherwise
      canMove - true if rows can be moved up or down in the table; false otherwise
    • showDialog

      public static InputTablePane showDialog(Component parent, String title, InputTablePane.ColSpec[] colspec, int nrows, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove)
      Create a new InputTablePane, initializing some rows, placing the table inside a dialog.
      Parameters:
      parent - the component on which to center the dialog
      title - the title of the dialog
      colspec - the column specification for the table
      initialRows - the rows to initially add to the table, placed as the first rows in the table
      nrows - the number of rows in the table
      canAdd - true if rows can be added to the table; false otherwise
      canDel - true if rows can be deleted from the table; false otherwise
      canMove - true if rows can be moved up or down in the table; false otherwise
    • showDialog

      public static int showDialog(Component parent, String title, InputTablePane ipane)
      Show a dialog containing an InputTablePane
      Parameters:
      parent - the component on which to center the dialog
      title - the title of the dialog
      ipane - the InputTablePane to display
      Returns:
      OK if the input is accepted; CANCEL if the input is cancelled