File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why use static method in creating gui

 
amit sharma
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am to new to swing.When i search tutorial for swing i see that most of them create gui in static method .What is the purpose of it .When i make gui in static method i am not able to add listener for it.Can anyone please tell me what is the preferred way of developing desktop application using swing.
Thanks
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you are talking about something like this:



The reason that createAndShowGUI() is static is because it's being called from a static method, main(String[] args). You can not call non-static methods from a static method, so createAndShowGUI() has to be static.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic