Re: Weird window close behavior
- From: Knute Johnson <nospam@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 27 Jun 2008 08:30:14 -0700
Lew wrote:
Knute Johnson wrote:So why wouldn't you construct a GUI in a GUI's constructor?
That depends on your definition of "construction". The OP's code follows the idiom you're probably used to seeing, where the GUI is assembled, but that is not the same thing as object construction in the Java, or O-O sense. So let's be precise in our terminology, shall we, and ask why one wouldn't assemble the _GUI_ in the _object_'s constructor?
The answer is what I said up front - it's a best practice not to do anything but construction (that's *object* construction, please avoid sophistry) in the object constructor. Properly speaking, the assembly of the GUI in an object, like the frame holder portrayed by both the OP's and my examples, should occur only after the object, the frame holder, is fully constructed.
This is the part that I am curious about. What makes it better practice to 'build' the GUI someplace other than the constructor? And to take that a step further, if you are building a GUI in a frame, why would it not be even better to build it totally in the main() method and avoid distributing the code out to the run()?
It was to show how one can translate that lip-service principle into practice that I presented the example.
Honestly, I'm just curious and want to understand the thinking behind your method. Are these best practices written down somewhere?
Thanks,
--
Knute Johnson
email s/nospam/knute2008/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
.
- Follow-Ups:
- Re: Weird window close behavior
- From: Lew
- Re: Weird window close behavior
- References:
- Weird window close behavior
- From: mrstephengross
- Re: Weird window close behavior
- From: Daniel Pitts
- Re: Weird window close behavior
- From: mrstephengross
- Re: Weird window close behavior
- From: Lew
- Re: Weird window close behavior
- From: Knute Johnson
- Re: Weird window close behavior
- From: Lew
- Re: Weird window close behavior
- From: Knute Johnson
- Re: Weird window close behavior
- From: Lew
- Weird window close behavior
- Prev by Date: KeyEventDispatcher receive a consumed event
- Next by Date: Re: (newbie) How to get the UI to update right away
- Previous by thread: Re: Weird window close behavior
- Next by thread: Re: Weird window close behavior
- Index(es):
Relevant Pages
|