Class JTreeTable

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
BalanceGroupTreeTable, ItemChargesTreeTable, PostPaidChargesTreeTable, PRemoveBillInProgressTreeTable, PRemovePaymentSetupTreeTable

public class JTreeTable extends JTable
original JTreeTable component taken from: Sun Microsystems, Inc. Copyright 1997, 1998 by Sun Microsystems, Inc.
Author:
lruslen
See Also:
  • Field Details

  • Constructor Details

    • JTreeTable

      public JTreeTable()
      Creates a new JTreeTable with a dummy TreeTableModel All beans must have a default no-args constructor
      See Also:
    • JTreeTable

      public JTreeTable(TreeTableNode root, Object[] columnNames)
      Returns a JTreeTable with the specified TreeTableNode as its root and the specified column names. By default, the tree defines a leaf node as any node without children.
    • JTreeTable

      public JTreeTable(TreeTableNode root, ArrayList columnNames)
      Returns a JTreeTable with the specified TreeTableNode as its root and the specified column names. By default, the tree defines a leaf node as any node without children.
    • JTreeTable

      public JTreeTable(TreeTableNode root, boolean asksAllowsChildren, Object[] columnNames)
      Returns a JTreeTable with the specified TreeTableNode as its root and the specified column names and which decides whether a node is a leaf node in the specified manner.
      Parameters:
      root - - a TreeNode object
      asksAllowsChildren - - if false, any node without children is a leaf node; if true, only nodes that do not allow children are leaf nodes
      columnNames - - names of each column
    • JTreeTable

      public JTreeTable(TreeTableNode root, boolean asksAllowsChildren, ArrayList columnNames)
      Returns a JTreeTable with the specified TreeTableNode as its root and the specified column names and which decides whether a node is a leaf node in the specified manner.
      Parameters:
      root - - a TreeNode object
      asksAllowsChildren - - if false, any node without children is a leaf node; if true, only nodes that do not allow children are leaf nodes
      columnNames - - names of each column
    • JTreeTable

      public JTreeTable(TreeTableModel treeTableModel)
      Creates a new JTreeTable.
      Type Parameters:
      em - treeTableModel data that will be used for component
      See Also:
  • Method Details

    • setHandleVisibility

      public void setHandleVisibility(boolean b)
      Sets the handles on the tree visible, or not. Not visible by default.
      Parameters:
      vis - - set to true to display handles; false for no handles
    • expandAll

      public void expandAll()
    • collapseAll

      public void collapseAll()
    • setTreeRenderer

      public void setTreeRenderer(TreeCellRenderer r)
    • setModel

      public void setModel(TreeTableModel newModel)
      Sets the data model for this component to newModel.
      Type Parameters:
      em - newModel data that will be used for component
      See Also:
    • getTreeTableModel

      public TreeTableModel getTreeTableModel()
      Returns:
      the tree table model for this tree table.
    • updateUI

      public void updateUI()
      Overridden to message super and forward the method to the tree. Since the tree is not actually in the component hieachy it will never receive this unless we forward it in this manner.
      Overrides:
      updateUI in class JTable
    • getEditingRow

      public int getEditingRow()
      Workaround for BasicTableUI anomaly. Make sure the UI never tries to paint the editor. The UI currently uses different techniques to paint the renderers and editors and overriding setBounds() below is not the right thing to do for an editor. Returning -1 for the editing row in this case, ensures the editor is never painted.
      Overrides:
      getEditingRow in class JTable
    • setRowHeight

      public void setRowHeight(int rowHeight)
      Overridden to pass the new rowHeight to the tree.
      Overrides:
      setRowHeight in class JTable
    • getTree

      public JTree getTree()
      Returns the tree that is being shared between the model.
    • tableChanged

      public void tableChanged(TableModelEvent e)
      Handle events from the TreeTableModelAdapter
      Specified by:
      tableChanged in interface TableModelListener
      Overrides:
      tableChanged in class JTable
      Parameters:
      e -
    • makeSortable

      public void makeSortable()
      Add a listener to the table header and sort the table whenever a column is clicked.
      Throws:
      IllegalArgumentException - if the model is not sortable
    • setAscendingIcon

      public void setAscendingIcon(Icon icon)
      Set the icon used to indicate that a column is sorted in ascending order.
      Parameters:
      icon -
    • setDescendingIcon

      public void setDescendingIcon(Icon icon)
      Set the icon used to indicate that a column is sorted in descending order.
      Parameters:
      icon -
    • getSortColumn

      public int getSortColumn()
      Which column was used to sort the tree table. Returns -1 if the tree table has not been sorted.
    • getSortAscending

      public boolean getSortAscending()
      Returns whether the tree table is sorted in ascending order.
    • setValueAt

      public void setValueAt(Object aValue, int row, int column)
      Whenever data is updated to the tree table,it will fire TreeTableDataChange event
      Overrides:
      setValueAt in class JTable
      Parameters:
      aValue - Object
      row - int
      column - int
    • addTreeTableDataListener

      public void addTreeTableDataListener(TreeTableDataListener l)
      Notify the given listener when the table row data changes
      Parameters:
      l - The selection listener
    • removeTreeTableDataListener

      public void removeTreeTableDataListener(TreeTableDataListener l)
      Don't notify the given listener when the table row data changes
      Parameters:
      l - The selection listener
    • fireTreeTableDataChanged

      public void fireTreeTableDataChanged(Object pValue, Object aValue, int row, int column)