Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dont understand this initialization issue  RSS feed

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • 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
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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: 1281
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!