An undocumented, mysterious class - garbage or design that I don't know?

I inherited the following code:

(Some names have been 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 did not immediately understand why this is important, so I came across a source tree to see its use. 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 can see, this is completely unnecessary. But this is my first job, I have not yet gone to college, etc., Therefore, I wonder if this is some kind of idiom, but unfamiliar to me.

PS - I'm also relatively new to SO. I believe that this question can be answered definitively, but it seems less technical than usual. If this is not good, let me know and I will take it off. (Or just change this: P)

+3
source share
1 answer

, JPanel, .

, JPanel ( demo).

, - - , . - , GUI . //Main panel in the GUI .

-, , ( ) - JPanel, . ( , ?)

+1

All Articles