Article View: borland.public.jbuilder.java.swing
Article #9198Re: Closing a JFrame from another class
From: Song Huang
Date: Thu, 11 May 2000 00:00
Date: Thu, 11 May 2000 00:00
37 lines
1911 bytes
1911 bytes
"John P. McGrath" wrote:
> You need to add a method to UsingMyGui that allows the other class to do
> this. One way would be to add a "getter" to UsingMyGui to get the MyGui
> object:
>
> MyGui getGui() {
> return myGui;
> }
>
> Another would be to add a method that just closes the GUI:
>
> void closeGui() {
> myGui.setVisible( false );
> }
>
> Which should you use? That depends a lot on the view that UsingMyGui
> wants to present to the outside world. Is the MyGui object simply part
> of the implementation of UsingMyGui? Should others know that it has a
> MyGui object, or should they just know that there is some sort of GUI
> that can be closed?
>
> If you have any doubts, I would recommend starting with approach #2.
Thanks John
The problem is: if i use approach #1, it will require mygui to be the class
variable in the UsingMyGui class(which i have mislead you in the example).
approach # 2, i don't think it is doable. because i don't have access to the
mygui variable.
what i am thinking about is having the operating system(ms windows) to
close/dispose it. Or is there a way to find out what is on display and use the
instanceof method to get the instance of MyGui, and close it that way?
Thanks
Technical Details
Message-ID:
<391AC9FC.C79095C6@mindspring.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3919CF22.3BAB6561@mindspring.com> <MPG.1383f716e6b0db2998990d@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,46f628b1b7c9f8ec X-Google-Attributes: gid111d45,public From: Song Huang <songhuang@mindspring.com> Subject: Re: Closing a JFrame from another class Date: 2000/05/11 Message-ID: <391AC9FC.C79095C6@mindspring.com> X-Deja-AN: 622136707 Content-Transfer-Encoding: 7bit References: <3919CF22.3BAB6561@mindspring.com> <MPG.1383f716e6b0db2998990d@forums.borland.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing