• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems Sizing a JTree

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to display a JTree within a ScrollPane. Works fine. However....
I'm trying to specify how much space I want the JTree to take up when the tree is initially displayed, whether or not the nodes are expanded (500 X 500 for example).
2 approaches fail for different reasons:
1. setPreferredSize() works initally (I get a Tree of 500 X 500), but then if there are a lot of hidden Nodes, when I expand , it never goes over this size, so it doesn't show the Nodes. They are not even able to be Scrolled into view- the ScrollPane never seems to acknowledge that I am trying to expand the view.
2. Not setting any size works in the sense that as I expand the Nodes, it adjusts the Tree size, and the ScrollPane viewport opens up to allow scrolling to the newly visible Nodes. BUT! in this case the initial size of the tree is set to whatever is the minimum possible to initally display the data (unexpanded). This is like 200 X 200. It eventually will go beyond 500 by 500 but until then it looks too small.
I tried setting Minumum Size but that seemed to be ignored. I am using a GridBagLayout. Is this part of the problem? But if GridBagLayout is ignoring my request for a MinimumSize, why wouldn't it also ignore my request for a Preferred Size?
Any advice?
 
reply
    Bookmark Topic Watch Topic
  • New Topic