Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

show() and setVisible(boolean)  RSS feed

 
Rex Isaacs
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm a beginner. I'd like to know whats the difference between show() and setVisible(true).
thanx.
regards
Rex
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They do the same thing, really, but "show()" is deprecated, which means that there's a superior replacement and you shouldn't use it in new code. The replacement, in this case, is setVisible().
 
Rex Isaacs
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx for the reply Earnest.
Thats true, i checked it. But technically it seems some difference. Please give some technical reasons.

Rex
 
Ananya Gupta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
show and setVisible(true) essentially do the same thing, though show is now deprecated for Component Class. BUT , it is not deprecated for the Window class. So if you are using the JFrame class, which inherits from the Window class, show can be used legally.Here show(), makes the window visible AND brings it to the front.Thats why it is superior to setVisible().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!