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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:06:18+00:00 2026-05-14T06:06:18+00:00

I have a Swing application that I would like to convert from spaghetti to

  • 0

I have a Swing application that I would like to convert from spaghetti to using dependency injection with Guice. Using Guice to provide services like configuration and task queues is going great but I’m now starting on the GUI of the app and am unsure of how to proceed.

The application is basically a JFrame with a bunch of tabs in a JTabbedPane. Each of the tabs is a separate JPanel subclass that lays out the various components and needs services to perform actions when certain buttons are pressed.

In the current application, this looks somewhat like this:

@Inject
public MainFrame(SomeService service, Executor ex, Configuration config) {
    tabsPane = new JTabbedPane();

    // Create the panels for each tab and add them to the tabbedpane
    somePanel = new SomeTabPanel(service, ex, config);
    tabsPane.addTab("Panel 1", somePanel);

    someOtherPanel = new SomeOtherTabPanel(service, ex, config);
    tabsPane.addTab("Panel 2", someOtherPanel);

    ... do more stuff
}

Obviously, this doesn’t exactly follow DI best practices. I don’t want to have to @Inject the tabs because that would get me a constructor with dozens of parameters. I do want to use Guice to inject the required dependencies into whatever tab objects I need without me having to pass all of those dependencies to the tab constructors.

All of the dependencies for the tab objects are services that my Module knows about, so basically all I think I want to do is to ask Guice for the required objects and have them constructed for me.

  • 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-14T06:06:18+00:00Added an answer on May 14, 2026 at 6:06 am

    Could you use Multibinding to bind all of your tabs as a Set? If they implemented some interface that allowed you to get the name to use for the tab, you could then just loop through adding the tabs from the set. You’d probably need to figure something out as far as ordering the tabs though.

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

Sidebar

Related Questions

I have a swing application that includes radio buttons on a form. I have
I have a Swing Application running under Linux, that has problems to display accented
I have a Java swing application with a panel that contains three JComboBoxe s
I have a Java Swing application, developed on Mac OS X 10.5 using Java
I am creating an touch screen application using Swing and have a request to
In the application I'm developping (in Java/swing), I have to show a full screen
I am making an application with Java Swing and i have a problem. I
I'm a newbie to swing development. I have a swing app that needs to
I have a swing gui with a tabbed pane in the north. Several key
I'm relatively new to java (specifically swing) and have recently been making some fairly

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.