Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing JLabel Resizing Question  RSS feed

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTree with JLabels for each node. When I change the text of a node
so that it is longer, it adds "..." to the end and cuts off some text.
Example:
Change "Hello Node"
To: "Hello Node New"
Results In: "Hello Nod..."
I have created my own DefaultTreeCellRenderer and in there am setting the
size of the JLabel (and preferrer size and min/max size) to be the width of
the new text string (using FontMetrics). Yet, it still cuts the string and
adds the dots. Does anyone know what I need to do to fix this?
Thanks!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get it to work by changing the value throught the model rather than through the node directly...

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!