Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why varing default in/visibility?  RSS feed

 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"All components, other than frames, windows, and dialogs, are visible by default. Invoking setVisible(true) on frames, windows and dialogs makes them visible."

What is the reason to have windows, frames and dialogs invisible and to add the work and memorizing efforts to programmers?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These components are intended to be top level components. All the other things go INSIDE a top level container - so when the top one gets visible all of the components inside it get visible at the same time.
Top level containers start out not visible to give the system time to add all the components and build the GUI without causing a flickering effect.
An Applet is the other major top level container - but the contract with the browser controls those. The init() method is run - allowing the GUI to be built - and THEN the start() method is called which makes it all visible.
------------------
Cindy Glass
Sun Certified Programmer for the Java� 2 Platform
Co-author of Java 2 Certification Passport
 
Suresh Bansal
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also it takes some time for the java program to create the screen(gui), so in case we want to display and close a particular screen repeatedly then its always better to play with the setVisible(boolean) function intead of calling dispose() and then creating the new instance of that window.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!