Results 1 to 4 of 4
  1. #1
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    148
    Rep Power
    0

    Default Basic GUI Question

    How comes I see some classes that extend JFrame and implement ActionListener and than there are other that don't but are still able to produce the GUI?

    Thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Basic GUI Question

    Because there is no requirement for a GUI class to either extend JFrame or implement ActionListener to use this functionality. If you need to display a GUI in a JFrame, then you can make the JFrame at the time it is needed. If you need to add an ActionListener to a JButton, then you can use an anonymous inner class or a separate external class that implements the interface.

  3. #3
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    148
    Rep Power
    0

    Default Re: Basic GUI Question

    Quote Originally Posted by Fubarable View Post
    Because there is no requirement for a GUI class to either extend JFrame or implement ActionListener to use this functionality. If you need to display a GUI in a JFrame, then you can make the JFrame at the time it is needed. If you need to add an ActionListener to a JButton, then you can use an anonymous inner class or a separate external class that implements the interface.
    What about creating the gui in the main method? How comes this works. Sorry for asking stupid questions but there are so many ways of making these guis i've become so confused. Thanks

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Basic GUI Question

    Quote Originally Posted by stuckonjava View Post
    What about creating the gui in the main method? How comes this works. Sorry for asking stupid questions but there are so many ways of making these guis i've become so confused. Thanks
    I'm not sure what exactly confuses you. If you need to create a JFrame in the main method, you can create a JFrame object and use it.

    Can you show code that confuses you and give the details of your questions?

Similar Threads

  1. please answer some basic question if you can
    By togaurav in forum New To Java
    Replies: 17
    Last Post: 04-16-2011, 08:23 AM
  2. Basic JSP question..
    By casid in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-28-2009, 06:51 PM
  3. Basic question on OOP.
    By madthinker in forum New To Java
    Replies: 7
    Last Post: 01-26-2009, 07:09 PM
  4. Basic question about EJB
    By javaplus in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-15-2008, 05:44 PM
  5. Very basic question
    By gvi in forum New To Java
    Replies: 2
    Last Post: 10-30-2007, 06:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •