Solved

Layout Manager Question

Posted on 2001-06-22
7
254 Views
Last Modified: 2008-10-13
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
Comment
Question by:jasper01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Expert Comment

by:oumer
ID: 6219290
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
 
LVL 1

Expert Comment

by:goldwarlock
ID: 6219550
USe null layout manager or XYLayout in JBuilder/Jdeveloper
0
 
LVL 1

Expert Comment

by:goldwarlock
ID: 6219610
btw: visit my site
www.xanga.com/goldwarlock
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:ozymandias
ID: 6219863
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
 
LVL 7

Accepted Solution

by:
Igor Bazarny earned 100 total points
ID: 6220179
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
 
LVL 1

Expert Comment

by:jimaricat072100
ID: 6222345
You try Absolute positioning with null Layout,..or u can simply make that to Box Layout nd fit in a BorderLayout West part.
0
 
LVL 1

Expert Comment

by:goldwarlock
ID: 6223252
If your application doesnt need to be resized automatiacally use GridBack (that's pane)

THEN use null layout or XYLayout
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 160
JavaFX TableView not displaying correctly 3 160
jsp insert to database example 2 89
jmeter usage 4 62
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question