• 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

Box... dynamically adjust strut width

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

I'm using a Box (box) as my custom TreeRenderer; I'm using a Horizontal Strut with in this box to get some padding between a "label" and a "button"


Can you please suggest ideas on dynamically setting the width for the strut? Is there any other component that I could use for the same purpose? Basically I want all the Buttons in box aligned starting from some point; no matter the depth of the node

Thanks in advance
Ravi
 
Marshal
Posts: 79464
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glue?
You have doubtless read the BoxLayout API page and the Java Tutorial page?
 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well;

Glue works but I need a dynamic control of the space. All I want to do is to set the space (i.e gap) between components dynamically. I'm sure its possible isn't it? Am I something here...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just a thought.

give 'width' some extra meat, then

this.add(Box.createHorizontalStrut(width-label.getPreferredSize().width));
 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Micheal;
That Doesn't seem to work for me:

Basically my GUI looks like this:

Root < fixed strut> Button
------Child1 <fixed strut> Button
------------Child1.1 < fixed strut> Button

Whereas what I want to do:
Root < variable strut> Button
------Child1 < variable strut> Button
------------Child1.1 < variable strut> Button

Any Ideas???
 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never Mind,

I actually separated my TreeCellRenderer and the Box; So basically I build the entire Box on the fly; so depending on the level of my node; I can set the glue. Thanks for all who responded.

Ravi
 
reply
    Bookmark Topic Watch Topic
  • New Topic