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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:41:27+00:00 2026-05-23T02:41:27+00:00

I inherited the following code: (Some names are changed to protect the innocent.) package

  • 0

I inherited the following code:

(Some names are changed to protect the innocent.)

package foo.bar.baz;
import javax.swing.JPanel;

//Main panel in the GUI
class DemoRootPanel extends JPanel {
    private final MainGUIClass demo;

    DemoRootPanel(MainGUIClass demo) {
        super();   
        this.demo = demo;
    }

    public MainGUIClass getDragAndDropPanelsDemo() {
        return demo;
    }
}

I didn’t immediately see why it was important, so I grepped through the source tree to see it being used. These are all the results:

$ ack -i rootpanel
DemoRootPanel.java
5:class DemoRootPanel extends JPanel {
8:    DemoRootPanel(MainGUIClass demo) {

MainGUIClass.java
70: private final DemoRootPanel rootPanel;
124:        rootPanel = new DemoRootPanel(MainGUIClass.this);
821:                    containerPanels.add(new ContainerPanel(rootPanel));
846:                            containerPanels.add(new ContainerPanel(rootPanel));
1777:               ContainerPanel newContainer = new ContainerPanel(rootPanel);

ContainerPanel.java
30: DemoRootPanel rootPanel;
49: public ContainerPanel(DemoRootPanel rootPanel) {
51:     this.rootPanel = rootPanel;

and

$ ack getDragAndDropPanelsDemo
DemoRootPanel.java
13:    public PileSortGUI getDragAndDropPanelsDemo() {

So as far as I see, it’s completely unnecessary. But this is my first job, I haven’t been to college yet, etcetera, so I’m wondering if it’s not some idiom that’s important but unfamiliar to me.

PS – I’m also relatively new to SO. I believe this question can be answered definitively, but it does seem less technical than normal. If it’s not okay, let me know and I’ll take it down. (Or just mod it 😛 )

  • 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-23T02:41:28+00:00Added an answer on May 23, 2026 at 2:41 am

    It looks like this is just an empty JPanel which additionally contains a reference to an object of the main class.

    It could be that this could be simply replaced by a plain JPanel (ommiting the demo argument).

    It could be that someone planned to used this class for some goal but forgot this later. Or someone misunderstood and thought that every GUI object one uses must have an own subclass. The comment //Main panel in the GUI looks like this.

    If you have someone who wrote this code, ask him (or her) – otherwise I would just replace its use with a simple JPanel to cut down the number of classes. (You have a version control system, don’t you?)

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

Sidebar

Related Questions

I have some inherited code which stores SMTP server, username, password in the system.net/mailSettings/smtp
I have inherited the following code snippet: <div id=topbox> <h3> <div class=compare_link>Compare Products</div> <input
I have a problem with the default package. Basically my project structure consists of
I got some help on here last night about getting an the index of
I'm using a literal to display some javascript on a product page control. Basically
I was happy enough to have inherited a terribly written SharePoint project. Apparently, the
Recently we decided to make a general guideline for certain Rails3 project. And we
I have an INSERT statement that looks like this: INSERT INTO officer (officer_number, name,
I have a two .NET assemblies which are registered as COM+ components and I'm
As it stands right now, I have a literal control on my page. In

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.