Class ArrayTable

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

public class ArrayTable extends JTable implements ActionListener
A JTable to display int, double and String array values. Version 1.1 uses a Timer to coalesce Refresh Table events
Version:
1.1
Author:
Douglas Brown, Wolfgang Christian
See Also:
  • Constructor Details

    • ArrayTable

      public ArrayTable(int[] array)
      Constructor for 1D int array.
      Parameters:
      array - the array
    • ArrayTable

      public ArrayTable(int[][] array)
      Constructor for 2D int array.
      Parameters:
      array - the array
    • ArrayTable

      public ArrayTable(double[] array)
      Constructor for 1D double array.
      Parameters:
      array - the array
    • ArrayTable

      public ArrayTable(double[][] array)
      Constructor for 2D double array.
      Parameters:
      array - the array
    • ArrayTable

      public ArrayTable(String[] array)
      Constructor for 1D String array.
      Parameters:
      array - the array
    • ArrayTable

      public ArrayTable(String[][] array)
      Constructor for 2D String array.
      Parameters:
      array - the array
    • ArrayTable

      public ArrayTable(boolean[] array)
      Constructor for 1D boolean array.
      Parameters:
      array - the array
    • ArrayTable

      public ArrayTable(boolean[][] array)
      Constructor for 2D boolean array.
      Parameters:
      array - the array
  • Method Details

    • init

      protected void init()
      Initializes the table.
    • editCellAt

      public boolean editCellAt(int row, int column, EventObject e)
      Starts editing the cell at row and column. Overrides JTable method.
      Overrides:
      editCellAt in class JTable
      Parameters:
      row - the row to be edited
      column - the column to be edited
      e - ignored
      Returns:
      false if the cell cannot be edited or the indices are invalid
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Performs the action for the refresh timer by refreshing the data in the DataTable.
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      evt -
    • setRefreshDelay

      public void setRefreshDelay(int delay)
      Sets the Timer's initial time delay (in milliseconds) to wait after the timer is started before firing the first event.
      Parameters:
      delay -
    • refreshTable

      public void refreshTable()
      Refresh the data in the table.
    • setNumericFormat

      public void setNumericFormat(String str)
      Sets the default numeric display format for all columns
      Parameters:
      defaultFormat -
    • setNumericFormat

      public void setNumericFormat(String[] str)
      Sets the numeric display format for each column
      Parameters:
      defaultFormat -
    • setFirstRowIndex

      public void setFirstRowIndex(int index)
      Sets the first row's index.
      Parameters:
      index -
    • setFirstColIndex

      public void setFirstColIndex(int index)
      Sets the first column's index.
      Parameters:
      index -
    • setRowNumberVisible

      public void setRowNumberVisible(boolean vis)
      Sets the display row number flag. Table displays row number.
      Parameters:
      vis - true<\code> if table display row number
    • setEditable

      public void setEditable(boolean editable)
      Sets the editable property.
      Parameters:
      editable - true allows editing of the cell values that are not locked.
    • isTransposed

      public boolean isTransposed()
      Returns true of the table's row and column values are interchanged.
      Returns:
    • setTransposed

      public void setTransposed(boolean transposed)
      Sets the transposed property for the array. A transposed array switches its row and column values in the display.
      Parameters:
      transposed -
    • setColumnNames

      public void setColumnNames(String[] names)
      Sets columns names.
      Parameters:
      names -
    • setColumnLock

      public void setColumnLock(int columnIndex, boolean locked)
      Sets the column's locked flag.
      Parameters:
      column - int
      locked - boolean
    • setColumnLocks

      public void setColumnLocks(boolean[] locked)
      Sets the lock flag for multiple columns. Previously set locks are cleared.
      Parameters:
      locked - boolean array
    • getFont

      public Font getFont()
      Gets the default font of this component.
      Specified by:
      getFont in interface MenuContainer
      Overrides:
      getFont in class Component
      Returns:
      this component's font
    • setFont

      public void setFont(Font font)
      Sets the font for this component.
      Overrides:
      setFont in class JComponent
      Parameters:
      font - the desired Font for this component
      See Also:
    • setForeground

      public void setForeground(Color color)
      Sets the foreground color of this component. It is up to the look and feel to honor this property, some may choose to ignore it.
      Overrides:
      setForeground in class JComponent
      Parameters:
      color - the desired foreground Color
      See Also:
    • setDataForeground

      public void setDataForeground(Color color)
      Sets the foreground color of the cell rendering component. It is up to the look and feel to honor this property, some may choose to ignore it.
      Parameters:
      color - the desired foreground Color
    • setBackground

      public void setBackground(Color color)
      Sets the background color of this component. It is up to the look and feel to honor this property, some may choose to ignore it.
      Overrides:
      setBackground in class JComponent
      Parameters:
      color - the desired background Color
      See Also:
    • setDataBackground

      public void setDataBackground(Color color)
      Sets the background color of the data cell rendering component. It is up to the look and feel to honor this property, some may choose to ignore it.
      Parameters:
      color - the desired background Color
    • getCellRenderer

      public TableCellRenderer getCellRenderer(int row, int column)
      Returns the renderer for a cell specified by row and column.
      Overrides:
      getCellRenderer in class JTable
      Parameters:
      row - the row number
      column - the column number
      Returns:
      the cell renderer