JTree with left and right text in cells?

What I'm trying to do is create a JTree with each cell containing normal text but also containing the right-hand side of the text for each cell (right-aligned to the edge of the tree, regardless of hierarchy level).

I tried to create my own TreeCellRenderer, but the cell sizes are not updated. I also tried this idea with a tree user interface, but I am experiencing similar problems.

I also tried to create a custom component with JPenel glued to the right of the tree. This was most successful, but I could not strengthen the trees on the right side and touch this additional panel:

alt text http://img718.imageshack.us/img718/3676/problem.png

+3
source share
1 answer

You can try using the JXTreeTable from the SwingX package .

jxtreetable example http://blogs.sun.com/geertjan/resource/outline-tim-browser.png

Then you define such an object with two columns (one for the tree, the other for the right-aligned text), and it should work fine.

So that it does not look like a table, I would recommend that you disable the header (setTableHeader (null)) and use their "packaging" methods to have optimal column sizes.

+1
source

Source: https://habr.com/ru/post/1729365/


All Articles