I am somewhat lost at this point: I try to create a JTable that is able to hold some kind of a Tree (JTree?) datastructure in the first column followed by data based on the tree Node in the other columns as illustrated in the following image:
That image shows the structure of my JTree. The red lines indicate the table structur that i would need to realize. Each Node in the Tree should be treatet like a single row in that table, etc. I hope it is clear what i try to achieve.
I tried an aproach like it was discussed here: JTable as a JTree Node and here Put JTable in the JTree but that doesn't fit my needs. I also read about the JXTreeTable from the SwingX project but it seems to be very hard to find any usefull examples. Also many links to solutions like this seem to lead to (no longer existing) sun websites and/or beeing redirected to the oracle site...
It would be awesome if someone could lead me into the right direction and/or provide some exmaple code on how to do this (right).
Any help would be appreciated ;).
So you can call table. getSelectionModel(). isSelectionEmpty() to find out if any row is selected.
Right-click the table and select "Properties." The table's properties display, including the columns. You click a column and change the heading to edit the current columns. To add a new column, click "New" and type a heading for the column.
You can use the getRowCount() method: Returns the number of rows that can be shown in the JTable , given unlimited space. If a RowSorter with a filter has been specified, the number of rows returned may differ from that of the underlying TableModel .
The JTree class is used to display the tree structured data or hierarchical data. JTree is a complex component. It has a 'root node' at the top most which is a parent for all nodes in the tree. It inherits JComponent class.
Create your own TreeTable component like in the following link : http://www.java2s.com/Code/Java/Swing-Components/JTreeTablecomponent.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With