File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Gui components alignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Gui components alignment" Watch "Gui components alignment" New topic
Author

Gui components alignment

Ayub ali khan
Ranch Hand

Joined: Oct 20, 2005
Posts: 380
    
    2
Hi,

I am using a GUI building application, here I can drag and drop the components to create a form. I need help in alignment of these components.

Each component has the following positioning attributes: Left,Top,width,Height. (in terms of %position in parent)

Suppose I have 5 labels and corresponding text fields. How can I calculate the values of Left,Top,width,Height for each component relative to the parent (canvas)?

example:

how to align the following Form:

--------------------------------------------------------------------
|
|First Name: -TextField----- |
|
|Second Name:--TextField----- |
|
|Address:--TextField------- |
|
|E-mail: --TextField------ |
|
|Telephone Number:--TextField----- |
|
| SubmitBtn |
|
---------------------------------------------------------------------------


Thanks and Best Regards

Ayub


SCEA part I,TOGAF Foundation
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> how to align the following Form:

panel_1(BorderLayout)
panel_2(gridLayout(1,2))//add panel_3 and panel_4 to this panel
panel_3(gridlayout(5,1))//add all labels to this panel
panel_4(gridlayout(5,1))//add all textfields to this panel
panel_5(leave as flowLayout)//add submit button to this panel
add panel_2 to panel_1(BorderLayout.CENTER)
add panel_5 to panel_1(BorderLayout.SOUTH)
Ayub ali khan
Ranch Hand

Joined: Oct 20, 2005
Posts: 380
    
    2
Hi Michael,

Thank you for the info. Currently I am using a different custom application. I am not using SWING.

Thanks and Best Regards

Ayub.
 
Consider Paul's rocket mass heater.
 
subject: Gui components alignment