3

It may seem a little bit strange, but is there a way to make the last node of JTree expand horizontally rather than vertically? My vertical tree nodes represent different discussion subjects (politics, culture, etc.) and each of those nodes has a list of Article objects. I really need to sort these articles by publication date and place them in the last tree node horizontally.

I hope I was clear, any help or a link is very appreciated. Thank you!

skaffman
  • 398,947
  • 96
  • 818
  • 769
stokastik
  • 81
  • 4
  • don't quite understand how that should look like - do you have a screenshot or sketch or point to any standard application with such a beast? Or (guessing from your treetable tag) something like a treeTable where only one node has column data? – kleopatra Apr 15 '11 at 12:31

1 Answers1

2

You would have to override the paintComponent() method for JTree and calculate when you were painting the last node. If you were, you would reposition the start point of the painting for the JLabel which I believe represents a leaf.

Regards,

Guido

Edit

From Sun:

Swing programs should override paintComponent().

Located on this Page: http://java.sun.com/products/jfc/tsc/articles/painting/

Guido Anselmi
  • 3,872
  • 8
  • 35
  • 58
  • high density of incorrectness: a) never override paint b) there is no concept of "SomeComponent represents a leaf" – kleopatra Apr 15 '11 at 12:26
  • 1
    @Kleo: I have overridden paintComponent() myself in the past for projects I am not sure where this rule is enshrined. And b) I am not sure where you are quoting from. I am sorry my answer did not make sense to you but I don't feel that your response and down vote were appropriate. I am always happy to have my answers improved upon. – Guido Anselmi Apr 15 '11 at 17:20
  • Thanks you, that seems a bit tough for me :). I will try it today. I was thinking maybe I could somehow embed a table to the last node. Yes, it is leaf. – stokastik Apr 16 '11 at 16:53