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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:50:41+00:00 2026-05-26T12:50:41+00:00

I have a GUI with nested panels(tabbed with nested panels and etc). I need

  • 0

I have a GUI with nested panels(tabbed with nested panels and etc). I need to pass domain object to deeply nested panel. I can think of two ways:

  • Instantiate all gui objects in one place, like frame class. That
    would make passing domain objects dead simple, but Frame class will
    be huge and hardly maintanable.

  • Each panel has its own class, where we instantiate and layout its
    components. Now its easy to maintain and classes are clean, but how
    do I pass down the chain my domain objects? I dont want to chain-pass
    them through constructors of panels that shouldn’t even know their
    existance. And top level panels would have a ton of these objects to
    start with.

Niether way seems like a soulution. How do you usually aproach this?

  • 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-26T12:50:42+00:00Added an answer on May 26, 2026 at 12:50 pm

    When I put together a Java Swing GUI, I have a data model for each major GUI element. Note that this isn’t an MVC pattern. This is more like a local MV pattern. If you want, you can consider GUI element listeners as the “controller”.

    Each panel has its own class, where we instantiate and layout its
    components. Now its easy to maintain and classes are clean, but how
    do I pass down the chain my domain objects?

    You have the right idea, although you shouldn’t have to do much passing.

    My JFrame (or JApplet) will have an associated model class of global type fields. An instance of this model class will usually be passed along to the children elements. This is to allow children elements to react properly when a menu option is selected (as an example)

    My JPanel(s) will have an associated model class that maintains the state of text or button children elements.

    More complicated children elements, like a JList or a JTree, already have an associated data model. I will probably wrap these associated data models into the JPanel model class for convenience.

    The children elements will trigger some sort of selection or action listener. Some of these listeners might need access to model classes besides the model class associated with the parent. In this case, you’re going to have to pass the instances of your model classes to the listeners.

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

Sidebar

Related Questions

I have a class library that is nested two+ layers under a main GUI
Broad design/architecture question. If you have nested components in a GUI, what's the most
I have a GUI application which can create many similar windows on desktop. All
How can I do this in c#? I have GUI and worker threads and
I have GUI window for users to write their feedback, comments, etc. in JTextArea
I want to have GUI application or Web app where I can view the
I have a GUI that is going to do a lot of disparate tasks.
I have a GUI app written in C++/CLI which has a load of configurable
i have this GUI screen shots from the design team which i needs to
I have a GUI program, which would call a cmd in this GUI program.

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.