Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

Layout Manager Question

Hi

I am having a problem getting my layout correct, the GUI I want to create should look something like the following:

     _____________________________
    |_____________________________|
    | _________....._____.............................|
    ||.....................|...|_____|....Label..............| <-- TextField
    ||.....................|.............................................|
    ||.....................|.............................................|
    ||.....................|...._____.............................|
    ||_________|...|_____|............................| <-- Button
    |_____________________________|

I have the list box created and displayed fine but and have created a panel to store the TextField, Label and Button as follows:

panel2.add(testName);
panel2.add(new JLabel("# of records");
panel2.add(runButton);

This gives me the three in a row ... any ideas as to what layou manager to use and how to put in gaps between them .... I've played about with a few managers but am ending up scrapping it and restarting as it's not doing what I need!

Some code snippets, or tips would be really appreciated!
Thanks
J

PS sorry about the dots but spaces wrecked the layout!
0
jasper01
Asked:
jasper01
1 Solution
 
oumerCommented:
I think the best layout is the gridbaglayout which gives you a lot of options, but it's a little more complex than the rest.
0
 
goldwarlockCommented:
USe null layout manager or XYLayout in JBuilder/Jdeveloper
0
 
goldwarlockCommented:
btw: visit my site
www.xanga.com/goldwarlock
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ozymandiasCommented:
You could use a Box and BoxLayout.

This allows you to create "glue", "struts" and "rigid areas" within the box to space out your components.
0
 
Igor BazarnyCommented:
Hi,

I would use BorderLayout for the right pane:

Panel rightTop = new Panel();
rightTop.add(testName);
rightTop.add(new Label("# of records"));

Panel right = new Panel();
right.setLayout(new BorderLayout());
right.add(rightTop, BorderLayout.NORTH);
right.add(runButton, BorderLayout.SOUTH); // Maybe some Panel around button to avoid stretching

And maybe BorderLayout again to make right pane same height as Listbox. Or simple GridBag. Or Box. There are many choices. I basically don't like to use GridBagLayout. And if you care about platform portability or possibility of resizing your window, don't even think about null or XYLayout.

Regards,
Igor Bazarny,
Brainbench MVP for Java 1
www.brainbench.com
0
 
jimaricat072100Commented:
You try Absolute positioning with null Layout,..or u can simply make that to Box Layout nd fit in a BorderLayout West part.
0
 
goldwarlockCommented:
If your application doesnt need to be resized automatiacally use GridBack (that's pane)

THEN use null layout or XYLayout
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now