[Erledigt] Using DockingFrames with panel parent instead of a frame

Hello,

I’m interested in using DockingFrames in my project. The problem is, that I don’t have a window, but just a panel as parent gui component (because I’m developing only one part of the user interface that is plugged into the frame). All sample code I have seen used a frame as the “parent” component. Isn’t it possible to use other container gui elements? It is not only that I don’t have access to the frame, the docking feature beeing available somewhere else than in my panel is undesirable. Can I use DockingFrames in this case?

Kind regards
Florian

You cannot use the Common-project (or to be more specific, you cannot create a CControl, which means about 90% of the stuff of Common is not accessible).

The core-library however does not require a main-frame. Some features will not work as nicely as one might hope, some will not be available at all, but it should not break down.

Of corse working only with the core-library means more work for you, not necessarely with a better outcome…

If you ask whether there is even a chance of success: the example applications “Notes” and “Help” are not using Common (or only a few small parts of it), they can show you what kind of features you can expect.
So my final answer: if you have the time to dig through the core-library than you can use DF, otherwise you might be better of with another framework.

(It would be a nice idea to change Common in a way that your problem can be solved, but that will not be available before 1.0.8 - and that is probably to late for you.)

[quote=Unregistered]Hello,

I’m interested in using DockingFrames in my project. The problem is, that I don’t have a window, but just a panel as parent gui component (because I’m developing only one part of the user interface that is plugged into the frame). All sample code I have seen used a frame as the “parent” component. Isn’t it possible to use other container gui elements? It is not only that I don’t have access to the frame, the docking feature beeing available somewhere else than in my panel is undesirable. Can I use DockingFrames in this case?

Kind regards
Florian[/quote]

I have used DockingFrames with a JPanel as the parent component. I guess I was able to fulfill my functionality using just the core-library.

Here is the simple algorithm I followed:

  1. create a DockFrontend
  2. create a SplitDockStation
  3. add the SplitDockStation as a root to the DockFrontend
  4. create dockable objects
  5. add them to the SplitDockStation
  6. Add splitDockStation.getComponent() to the JPanel

Hope that helps


Regards
Parag Shah

Thank you for your answers.

@Beni: I had a look at both sample projects (held and editor), but both of them created a DockFrontend by passing a frame to the controller.

@Parag: I tried your algorithm, but it did not work as expected. The following code creates a window with a magenta-colored panel, that should act as dockstation. But the yellow-colored dockable panel is not shown. When I add the splitDockStation.getComponent() directly to the frame it works, but this is not possible in my real project. Where is my fault? Any ideas?

    frame.setSize(600, 600);
    frame.setLayout(new BorderLayout());
    
    JPanel dockStationPanel = new JPanel();
    dockStationPanel.setBackground(Color.MAGENTA);
    frame.add(dockStationPanel, BorderLayout.CENTER);
    
    // 1. create a DockFrontend
    DockFrontend frontend = new DockFrontend();
    // 2. create a SplitDockStation
    SplitDockStation splitDockStation = new SplitDockStation();
    // 3. add the SplitDockStation as a root to the DockFrontend
    frontend.addRoot(splitDockStation, "RootStation");
    
    // 4. create dockable objects
    JPanel dockablePanel = new JPanel();
    dockablePanel.setOpaque( true );
    dockablePanel.setBackground( Color.YELLOW );
    
    // 5. add them to the SplitDockStation
    splitDockStation.drop(new DefaultDockable(dockablePanel, "DockablePanel"));
    
    // 6. Add splitDockStation.getComponent() to the JPanel
    // works when I replace the following line by frame.add(splitDockStation.getComponent());
    dockStationPanel.add(splitDockStation.getComponent());
    
    frame.setVisible(true);```

Use a LayoutManager for dockStationPanel… :wink:

        frame.setSize(600, 600);
        frame.setLayout(new BorderLayout());
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
       
        JPanel dockStationPanel = new JPanel();
        dockStationPanel.setBackground(Color.MAGENTA);
        dockStationPanel.setLayout( new BorderLayout() );
        frame.add(dockStationPanel, BorderLayout.CENTER);
       
        // 1. create a DockFrontend
        DockFrontend frontend = new DockFrontend();
        // 2. create a SplitDockStation
        SplitDockStation splitDockStation = new SplitDockStation();
        // 3. add the SplitDockStation as a root to the DockFrontend
        frontend.addRoot(splitDockStation, "RootStation");
       
        // 4. create dockable objects
        JPanel dockablePanel = new JPanel();
        dockablePanel.setOpaque( true );
        dockablePanel.setBackground( Color.YELLOW );
       
        // 5. add them to the SplitDockStation
        splitDockStation.drop(new DefaultDockable(dockablePanel, "DockablePanel"));
       
        // 6. Add splitDockStation.getComponent() to the JPanel
        // works when I replace the following line by frame.add(splitDockStation.getComponent());
        dockStationPanel.add(splitDockStation.getComponent(), BorderLayout.CENTER );
       
        frame.setVisible(true);

Vielen Dank. Manchmal ist man echt zu blöd… :grr:

I’ve changed some parts, CControl can now be created without a frame. DF no longer needs to know the applications main-frame, but uses a “WindowProvider” which might (but is not required to) find the main-window. There is a provider called “ComponentWindowProvider” which observes a Component and returns the ancestor-window of that Component.

I will upload version 1.0.7 p2 before sunday (but not today).

(Yeah, I know, I said something about “not now”, “version 1.0.8”. But I recently worked with SWT and I just realized how simple this modification was.)

[Edit: is now available, put not really tested yet]