• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Alignment Issue

 
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..>>
Align-Issue.png
[Thumbnail for Align-Issue.png]
Align Issue
normal-look.png
[Thumbnail for normal-look.png]
Normal Look
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 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
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow!! That was amazing!!! Now my code looks exactly how it should look!! Thanks a lot for your help!! I really appreciate it!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic