Article View: borland.public.jbuilder.java.swing
Article #9743Re: jframe.setVisable() - why does JBuilder use it?
From: John P. McGrath
Date: Fri, 14 Jan 2000 00:00
Date: Fri, 14 Jan 2000 00:00
48 lines
2195 bytes
2195 bytes
On Thu, 13 Jan 2000 19:33:16 -0500, Timothy Reaves wrote:
> rwilkman wrote:
>
> > Component.show() (which is where this eventually ends up)
> > was deprecated in 1.1. It's a JDK 1.0 call.
>
> Yes, but Window.show() is NOT deprecated. It is a better
> method to use, is it not?
It is not better, at least in terms of the behavior of the program. The
program will behave the same, no matter which one you call. This is
because JFrame inherits setVisible(boolean) from Component, which is
implemented as follows:
public void setVisible(boolean b) {
show(b);
}
public void show(boolean b) {
if (b) {
show();
} else {
hide();
}
}
Since all setVisible(true) on a JFrame does is to call the show() method,
which is overridden by the JFrame show() method, it has the same
behavior. Similarly, Dialog.setVisible(true) ends up calling the Dialog
show() method.
The docs for Window.show() says that it will bring the Window to the
front. The docs for Component.setVisible(boolean) do not mention this,
because it applies to other Components besides Windows, and it does not
have that behavior for the other types of Components. Similarly, the
docs for the Dialog show() method describe the effects of show() on a
modal dialog, but those behaviors also apply to setVisible(true) on a
Dialog.
I have always wondered why the Component show() method was deprecated,
but the Window and Dialog show() methods were not. I am sure there is
some reason for it, but I cannot figure it out.
--
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID:
<MPG.12e8b5e57aa506c7989730@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<387E3A18.A9E5A194@silverfields.com> <387E49DA.1DADD44E@inprise.com> <387E6ECC.314D5BA2@silverfields.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,95d45e4244dd334e X-Google-Attributes: gid111d45,public From: John P. McGrath <JPMcGrath@fast.net> Subject: Re: jframe.setVisable() - why does JBuilder use it? Date: 2000/01/14 Message-ID: <MPG.12e8b5e57aa506c7989730@forums.borland.com> X-Deja-AN: 572488686 References: <387E3A18.A9E5A194@silverfields.com> <387E49DA.1DADD44E@inprise.com> <387E6ECC.314D5BA2@silverfields.com> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing