Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6989791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:15:35+00:00 2026-05-27T19:15:35+00:00

In the GUI book we use in class there are many examples of how

  • 0

In the GUI book we use in class there are many examples of how graphical user interfaces are made in Java. So many examples, that I’m very confused regarding which one should be used when it comes down to a big application.

So I’ve seen examples

  • in which the main class extends JFrame
  • where the JFrame object is created inside the main method
  • where the main class extends JFrame AND implements ActionEvent interface
  • where Listener classes are declared inside the main class

Sure, I can work with all of these, but right now, as I don’t have any kind of experience, I don’t see the benefit of using any of them. Is actually one of them the correct way to do it or it depends on my sittuation?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:15:36+00:00Added an answer on May 27, 2026 at 7:15 pm

    "Is A" or "Has A"? This is the question that should be asked when considering extending a class. If the new class "Is A" frame, extend frame, but if the class just needs a reference to a frame, don’t extend.

    In fact, if a custom component is required, extend a JComponent or JPanel, then add that to a frame, ..applet, window, JInternalFrame, dialog, constraint of a layout, part of a split pane..

    Listeners

    As to the listeners. Rather than traverse a huge if/else structure in the single actionPerformed() method to determine the required action, it is more optimal to either:

    1. Create a listener for each control that needs it.
    2. Create an instance of an AbstractAction that might be used for multiple controls (‘copy’ button, menu item etc.).

    Summary

    So (generally) for the:

    1. JFrame, don’t extend.
    2. Listeners, create and add as needed.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is basic example I got for a GUI from a book called Java
I'm making a simple address book GUI and I don't have a very good
in the book that i'm reading, every example of GUI with multithreading has something
Is there any book or very informative tutorial site which can help newbies learn
In this Java desktop GUI, the web services communication layer is in Java, the
Part of the GUI I'm building using tkinter has a pop-up window that says
I've recently began working through a C++ Gui Programming with Qt 4 book. However,
Guys from book C++ GUI programming with qt I'm reading a chapter on how
From reading parts of the Programming in Scala book, I realize that Scala can
So, I'm reading this book: C++ GUI Programming with Qt 4, Second Edition by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.