This is largely off-topic but might be educational on some aspect.
A major percentage of beginners' Swing code use show() method for
JFrame visibility. Of course it gets compiler warning.
Why on earth youngest generation keep using an old deprecated API
in such a prevailing way?
>From some point of time, Swing designers have surrendered to the
JavaBeans convention of class structure and member naming. We have
torrent of get/is/set methods today. Why so many of beginners could be
immune to the trend?
Monique Y. Mudama - 06 Oct 2005 01:41 GMT
> This is largely off-topic but might be educational on some aspect.
>
[quoted text clipped - 8 lines]
> torrent of get/is/set methods today. Why so many of beginners could
> be immune to the trend?
show() conveys the intent much more readily than setVisible(true)?
Honestly, bean conventions be damned, show() is much more sensible. I
use setVisible(true), but only because I don't want to see the
warnings.

Signature
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Roedy Green - 06 Oct 2005 02:18 GMT
>Honestly, bean conventions be damned, show() is much more sensible. I
>use setVisible(true), but only because I don't want to see the
>warnings.
From an English language point of view, the old names show() and
hide() are more accurate. You are not just setting a visibility
property. You are causing work to be done to actually show the
component.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Andrew Thompson - 06 Oct 2005 02:41 GMT
>>Honestly, bean conventions be damned, show() is much more sensible. I
>>use setVisible(true), but only because I don't want to see the
[quoted text clipped - 4 lines]
> property. You are causing work to be done to actually show the
> component.
Does that work get done on second and subsequent
calls to setVisible(true)?
If not 'constructAndShow()' would be more accurate for
the first invocation, while 'setVisible(true)' better
represents the subsequent calls.
Of course, it is better to use one or the other consistently.
I prefer setVisible(true) simply for the consistency
with set/get.
On the matter of why there is still so much of it..
- I agree with Monique
'show() conveys the intent much more readily than setVisible(true)'
- show() was only deprecated in 1.5.
Roedy Green - 06 Oct 2005 02:14 GMT
>Why on earth youngest generation keep using an old deprecated API
>in such a prevailing way?
It is shorter to type.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Roedy Green - 06 Oct 2005 02:15 GMT
>Why on earth youngest generation keep using an old deprecated API
>in such a prevailing way?
They are reading older text books and sample code that have not been
updated.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Andrew Thompson - 06 Oct 2005 02:43 GMT
>>Why on earth youngest generation keep using an old deprecated API
>>in such a prevailing way?
>
> They are reading older text books and sample code that have not been
> updated.
The vast majority of Sun example codes, as one
(significant) example..
ajay - 06 Oct 2005 09:16 GMT
Oh all the good people on the bench try to show() something.
Well i think all of you are right.
The major reason behind using show() method is read from
some older books just as i do before coming on this forum
but it runs fine under jdk1.4.1. I read from dietel and dietel 3rd
edition.
I only know it from Andrew that it can be replaced with setVisible().
I only need to know is it alright to use setSize(x,y) before
setVisible().
Or any other api will do this.
Roedy Green - 06 Oct 2005 18:49 GMT
>I only need to know is it alright to use setSize(x,y) before
>setVisible().
see http://mindprod.com/jgloss/layout.html
Most of the time you let the layout manager do the setSize for you.
For JFrames you do the setSize, then validate() then setVisible(true).
See http://mindprod.com/jgloss/jframe.html
http://mindprod.com/jgloss/frame.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
ajay - 06 Oct 2005 19:19 GMT
Thanks Roedy,
I am just like your student learning new things.
Please see my coordinate mapping problem i already search across
200 pages on the net,but didn't able to solve the problem!
Please help to solve it.