• 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

Dont understand this initialization issue

 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
playing around with alignning (bottom's) components with BoxLayout layout i came to the following code (which met my needs)
i created three panels and then tried to bottom align them, succeeding:

as all this worked fine, i decided to further refactor: i commented out the assignment of the return methods, substituting xxxPanel for getxxxPanel():


and suddenly the buttonPanel got an incorrect alignment

what is the reason of this behaviour?
i'm convinced it has nothing to do with swing, but instead is a problem related with some lack of initialization, which i just cant sort it out

can someone please explain it?

thanks in advance
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those getXXXPanel methods return a different object every time you call them, don't they? So your refactoring isn't equivalent to the original code.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Those getXXXPanel methods return a different object every time you call them, don't they? So your refactoring isn't equivalent to the original code.


of course! after reading your answer it looks quite obvious (new xxx() everytime)
thanks a lot
 
Evil is afoot. But this tiny ad is just an ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic