jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes Positioning components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Positioning components" Watch "Positioning components" New topic

Positioning components

Brett Thomas

Joined: Aug 25, 2011
Posts: 6
Hi all. I've read a couple of beginner books on Java - but I'm still a novice. After writing several programs contained in the books, I decided to tackle converting a very simple VB6 program into a Java applet that I can embed in a web page on my server. The VB6 program is something I wrote for a buddy several years ago. I included a screen shot of it. The user inputs two parameters, clicks the Accept button, and the program fills out the bottom 15 labels with numbers. Each number has a slightly different, short description under it. I changed the captions and such, but it has the look & feel I'm trying to duplicate in my applet. I'm having a very hard time figuring out how to position those objects in my applet to look similar to the VB6 program. I'd love some general tips on how I should go about tackling this (e.g. which layout managers I should use, if I should use two JPanels, if I should use layout managers within the panels, etc.).

Thanks for any help!

[Thumbnail for screen.jpg]

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46352
Yes, you should be using a layout manager. I shall move this discussion to our GUIs forum.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2451
Start with the Swing tutorial on Layout Managers to become familiar with the different layouts and their features.

Then you would likely combine multiple panels with multiple layout managers to get the desired effects.

For example maybe for the top you have a BoxLayout or a GridBagLayout to display multiple panels vertically. Then for each row you create a panel with a FlowLayout and add your components to then.

For the bottom half the same idea. Pick a layout to align multiple panels vertically. Then maybe you have a panel with a GridLayout for your combination of text fields and labels.

You can only learn by experimenting.
I agree. Here's the link: http://aspose.com/file-tools
subject: Positioning components
It's not a secret anymore!