Class DynamicTreeTableModel

  • All Implemented Interfaces:
    TreeTableModel, javax.swing.tree.TreeModel

    public class DynamicTreeTableModel
    extends AbstractTreeTableModel
    An implementation of TreeTableModel that uses reflection to answer TableModel methods. This works off a handful of values. A TreeNode is used to answer all the TreeModel related methods (similiar to AbstractTreeTableModel and DefaultTreeModel). The column names are specified in the constructor. The values for the columns are dynamically obtained via reflection, you simply provide the method names. The methods used to set a particular value are also specified as an array of method names, a null method name, or null array indicates the column isn't editable. And the class types, used for the TableModel method getColumnClass are specified in the constructor.
    • Constructor Detail

      • DynamicTreeTableModel

        public DynamicTreeTableModel​(javax.swing.tree.TreeNode root,
                                     java.lang.String[] columnNames,
                                     java.lang.String[] getterMethodNames,
                                     java.lang.String[] setterMethodNames,
                                     java.lang.Class[] cTypes)
        Constructor for creating a DynamicTreeTableModel.
    • Method Detail

      • getChildCount

        public int getChildCount​(java.lang.Object node)
        TreeModel method to return the number of children of a particular node. Since node is a TreeNode, this can be answered via the TreeNode method getChildCount.
      • getChild

        public java.lang.Object getChild​(java.lang.Object node,
                                         int i)
        TreeModel method to locate a particular child of the specified node. Since node is a TreeNode, this can be answered via the TreeNode method getChild.
      • isLeaf

        public boolean isLeaf​(java.lang.Object node)
        TreeModel method to determine if a node is a leaf. Since node is a TreeNode, this can be answered via the TreeNode method isLeaf.
        Specified by:
        isLeaf in interface javax.swing.tree.TreeModel
        Overrides:
        isLeaf in class AbstractTreeTableModel
      • getColumnCount

        public int getColumnCount()
        Returns the number of column names passed into the constructor.
      • getColumnName

        public java.lang.String getColumnName​(int column)
        Returns the column name passed into the constructor.
      • getValueAt

        public java.lang.Object getValueAt​(java.lang.Object node,
                                           int column)
        Returns the value for the column column and object node. The return value is determined by invoking the method specified in constructor for the passed in column.
      • setValueAt

        public void setValueAt​(java.lang.Object aValue,
                               java.lang.Object node,
                               int column)
        Sets the value to aValue for the object node in column column. This is done by using the setter method name, and coercing the passed in value to the specified type.
        Specified by:
        setValueAt in interface TreeTableModel
        Overrides:
        setValueAt in class AbstractTreeTableModel