Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Need suggestion reg Layout Managers

 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am generating set of JLabel and Checkboes on the fly dynamically in a JPanel.

JLabel1 chbk1 chbk2 chbk3 chbk4
JLabel2 chbk1 chbk2 chbk3 chbk4 chbk5 chbk6
...
..
.

And the list grows. Each set of JLabel followed by chbks are generated in one step. The number of checkboxes vary in each and every step.

All tehse elements are right now in a JPanel and unfortunately I couldn't figure out a proper layout manager for this scenario. Can any one suggest a solution.
[ April 10, 2008: Message edited by: Gopu Akraju ]
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about somewhat like this?



-mainPanel - BoxLayout wiht Y_Axis
[
[FlowLayout with Left alignment]
[FlowLayout with Left alignment]
[FlowLayout with Left alignment]
]
[ April 10, 2008: Message edited by: Edwin Dalorzo ]
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Edwin for the suggestion. Let me explain my scenario bit more clearly.
Every time I press a button, I will be displaying one label followed by few check boxes. The list grows when I press the button again. Every time I will get one label followed by few check boxes.

Does you logic still hold good in this situation? Infact with normal JPanel and FlowLayout, the list was growing perfectly fine and when I try putting the panel into a scrollable pan, all the components started growing horizontally in one single line with horizontal bar.

Let me try your logic for now as I have been running around the bush for few days without any solution. Thanks.
 
Author
Posts: 974
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gopu Akraju:
Thanks Edwin for the suggestion. Let me explain my scenario bit more clearly.
Every time I press a button, I will be displaying one label followed by few check boxes. The list grows when I press the button again. Every time I will get one label followed by few check boxes.

Does you logic still hold good in this situation? Infact with normal JPanel and FlowLayout, the list was growing perfectly fine and when I try putting the panel into a scrollable pan, all the components started growing horizontally in one single line with horizontal bar.



Yes, his suggestion is still valid in this situation. He's using one FlowLayout
per set, and you want each set "growing horizontally in one single line," right?

btw, it's good you described your requirements better, but is there a
reason you started a new thread instead of continuing with the old one?

[edit: Now that I understand that the number of Components in each row
will vary, I withdraw my previous suggestion to use GridLayout(0, N).]
[ April 10, 2008: Message edited by: Brian Cole ]
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes you are right. Instead of running around the bush again, I thought let me explain my problem from the scratch and get someone's suggestion. Hence. started a new thread. Let me try it and get back to you all. Thanks.
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The logic works fine. Every set of components are added in signle line. Again I am back to square problem. If I start using scrollable pane, the components are added in one single horizontal line with horizontal bar? Is there any trick to over write this?
 
Brian Cole
Author
Posts: 974
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gopu Akraju:
Instead of running around the bush again, I thought let me explain my problem from the scratch and get someone's suggestion. Hence. started a new thread.



Explaining your problem from scratch is good (in fact, perhaps you
should do so again, see below) but there was no reason to start a
new thread.

The logic works fine. Every set of components are added in signle line. Again I am back to square problem. If I start using scrollable pane, the components are added in one single horizontal line with horizontal bar?



From your description I thought you wanted each set to be in a single line that would scroll if it got too wide. If not, please explain what you are looking for.

If you want each set to wrap, you could use GridLayout(GridLayout(0, N))
for each set's panel, but you would have to hard-code the N (and also it wouldn't play very nice with an enclosing scroll pane). If you want them to wrap dynamically you could try Mr. Prime's JViewportFlowLayout that he helpfully provided in your previous thread on this topic.
[ April 11, 2008: Message edited by: Brian Cole ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic