aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Alignment Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Alignment Issue" Watch "Alignment Issue" New topic
Author

Alignment Issue

Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 497

Hi,

Please have a look at the following code

Form.java




Main.java




In here, I add items using the "add" button. Then, the names of the items, locations of the items and the size of the items will be displayed in the Boxes called "nameBox", "locationBox" and "sizeBox". "nameBox" contains JCheckBoxes and other two contains JLabels.

Now, the problem is, when I add items, the "nameBox" goes down, while other boxes are in their correct position. When I add more items, it goes more down. I am attaching two images explaining the normal look and with my Box Down problem. Please help me..>>



[Thumbnail for Align Issue.png]


[Thumbnail for normal look.png]



Are you better than me? Then please show me my mistakes..
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Please have a look at the following code

467 lines of uncompilable code? you must be joking.

in that state, if you want it fixed, you'd have to pay someone.

if you really want us to help, strip out everything unrelated
(e.g. are the images part of the problem, if not why are they there)

just use a frame with 2 or 3 components to reproduce your alignment problem,
then post that code here (should be 30 lines max), and make sure we can
copy/paste/compile/run and observe the problem.



Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 497

Thanks for the reply. Anyway, the code I have posted before is less than half of my original code. However, I edited it and reduced the code as much as I can. There is no way I can reduce it to 30 lines, because it will never address my original issue. Please help.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
it seems your problem is:

1) the differing heights of the checkbox and those of the labels.
2) the addition of a JPanel to both locationBox and sizeBox in addItems()

add the 2 indicated lines in AddAction()



also, don't call updateUI() directly, change updateInterface() to this
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 497

Wow!! That was amazing!!! Now my code looks exactly how it should look!! Thanks a lot for your help!! I really appreciate it!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Alignment Issue
 
Similar Threads
JTabbedpane with JRadiobutton?
help me create Go! game please
Image Resize on window Resize
AWT FlowLayout to BorderLayout
Head First Java BeatBox, wont compile!