Re: Weird window close behavior



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
.



Relevant Pages

  • Re: best way to get data into a new instance?
    ... I'm trying to construct it in a way that is independent of, say, the GUI interface that will be used, but I can't help but think that if all the data is entered into a GUI, then passed programmatically to the class, then it's no big deal because it happens behind the scenes. ... Granted, even with the GUI they are basically typing in arguments, but in the manual case you'd have to type in the call to the class, the parentheses, commas, quotes around the strings, etc. (But still, I'm trying not to let a specific interface influence the construction of what should probably be a completely independent class implementation.) ... The programmer is responsible for the construction of new instances, and a constructor should contain parameters for at least the values you absolutely expect to be there - for example name and age or something like that in your example. ...
    (comp.lang.python)
  • Building GUIs in the EDT and splash screens.
    ... I would like to get a bit of advice on the issue of building GUIs ... Sun now recommends doing all GUI-related construction ... But I'm not sure how to go about doing a mildly time-consuming GUI ... final variables to pass the object in to the Invoke later instances. ...
    (comp.lang.java.gui)
  • [c++] Concepts of multiple header/source files
    ... Just learning c++ here and am ready to start delving into the construction ... of larger applications which require the separation of gui and logic. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Weird window close behavior
    ... So let's be precise in our terminology, shall we, and ask why one wouldn't assemble the ... The answer is what I said up front - it's a best practice not to do anything but construction 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. ...
    (comp.lang.java.gui)
  • Re: Random non-binding survey on naming
    ... How would you do that in a GUI? ... I remember early in the Mac's life seeing a program that allowed construction of quite complicated mathematical equations with a tool palette of components that could be dragged into position and shifted around relative to each other. ... I could picture something similar that would allow construction of REs, and maybe let them be displayed in a way that made it easier for me to remember what all the.?* mean, and in a way that would allow REs with those symbols as actual search parameters to look similar to REs with other characters as search parameters. ...
    (rec.arts.sf.composition)