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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:48:28+00:00 2026-06-02T07:48:28+00:00

I have recently come across a problem trying to implement Model-View-Controller in Swing .

  • 0

I have recently come across a problem trying to implement Model-View-Controller in Swing.

I have a GUI class which consists of sub-panels, and those sub-panels consist of other sub-panels. Now in one of these sub-sub panels there is a JButton. In the ActionListener for this JButton I want to call a method in the controller. In order to do this I would need to pass the controller deep into the bowels of the GUI to the sub-sub panel where the JButton resides. Then in this sub-sub panel I would need to attach an ActionListener to the JButton and fill out the actionPerformed() by calling the method that I wanted to call in the controller.

I’m sure you all see the problem. Is there any good way of avoiding passing the controller deep into the bowels of the GUI.

My only thought was to make the controller a Singleton to decouple it from the view, but I have heard that Singleton’s are usually evil.

Any advice on this matter would be most appreciated.

  • 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-06-02T07:48:30+00:00Added an answer on June 2, 2026 at 7:48 am

    Instead of passing in a reference to the controller, let the controller listen to the view, as suggested by the indirect association pictured here. Adding a PropertyChangeListener, illustrated here, is ideal for this. When the view needs to call upon the controller, it simply invokes firePropertyChange().

    A more expedient approach is to give the controller a separate view for certain operations such as the reset() method shown here.

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

Sidebar

Related Questions

I've recently come across the ConditionalWeakTable<TKey,TValue> class in my search for an IDictionary which
Ive come across a nice problem recently, I have a Map LinkedHashMap<String, List<MyCustomObject>> I
So I'm writing some code and have recently come across the need to implement
I'm teaching myself VB.Net. Here is a problem I have recently come across. Say
I have recently come across a situation where code is dynamically loading some libraries,
I have recently come across an interesting question on strings. Suppose you are given
My co-worker and I have come across this warning message a couple times recently.
Recently I've come across a problem in my project. I normally compile it in
Possible Duplicate: What is the “??” operator for? I have recently come across the
I have recently come across the same hanging ‘XD Proxy’ in all browsers when

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.