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 7063397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:42:31+00:00 2026-05-28T04:42:31+00:00

I have a class which extends JFrame and forms the GUI of my program.

  • 0

I have a class which extends JFrame and forms the GUI of my program. I want to use the GUI for two main purposes:

  1. I want the user to be able to input values to the program.
  2. I want the GUI to display values created by my program.

Considering my class has a lot of GUI elements, the source file is already rather large and It does not seem like good practice to bundle all the program code in with the GUI code. I’m wondering what is the best way to structure my code? I believe there is an issue where requirement 1 creates a dependency from the GUI to the program code, and the second requirement does the opposite.

So, I want one class for my GUI which contains all my GUI related tasks. I then want another class for my program logic. I should then be able to call methods from the program logic class from the GUI and vice versa.

  • 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-28T04:42:32+00:00Added an answer on May 28, 2026 at 4:42 am

    Sounds like you are looking for a textbook MVC (Model-View-Controller) design pattern. I recommend you google “MVC Design Pattern” for summaries and use cases. That being said, you might want to put your program logic into a “Singleton” class (again, google “Singleton Design Pattern”). A properly implemented Singleton should be accessible from any other class in your code.

    Consider also a third middle class which acts solely for data storage, you put values into it for storage, and you fetch values from it for work. This now creates 3 clear segments for your code, the Data (the Model), the GUI (the View), and the logic (the Controller). Voila, you’ve just implemented the MVC (Model-View-Controller) design pattern…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Java JFrame class, in which I want to use a boxlayout,
I have a JFrame (well, a class which extends JFrame) and I want to
I have 2 web user controls, both inherit the same base class which extends
I have two Java classes: B, which extends another class A, as follows :
I have a Layout class which extends JFrame . Later I am adding RoadPanel
I have a main program, in which GUI is based on swing and depending
I have a JFrame . I also have a Box class which extends Component
I have a custom class loader which extends from a URLClassLoader. I added a
I have a view in Eclipse (implemented by a class which extends org.eclipse.ui.part.ViewPart )
I have an abstract class Airplane, and two classes PassengerAirplane and CargoAirplane, which extend

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.