Monday, August 3, 2009

Tree model and table model are the 2 complex jcomponent models. Each adds a meaningful *structure* to an otherwise unorganized constellation of objects, a structure naturally suited to the target jcomponent.

1) If you stop and think of the typical kind of data organized into a jtable, it's really a collection of ROWS. Each row contains a strictly ordered list of objects. Order is fixed, so is each data type -- First object must be age, 2nd object must be gender ... Therefore it's logical and natural to use a collection of DOMAIN objects.

2) A jtree maps naturally to any hierarchical data. Interestingly, the TreeModel interface accepts any kind of object as a tree node and does not require that nodes be represented by DefaultMutableTreeNode, or even that nodes implement the TreeNode interface. If you have a pre-existing hierarchical data structure, you do not need to duplicate it or force it into the TreeNode mold. You just need to implement your tree model so that it uses the information in the existing data structure.