Dockable parent station

Hi,

I have created 6 stations and want to add dockable to those stations. I’m trying to do it as below but it’s not working. Could you please help?

SplitDockStationsplit = new SplitDockStation();
FlapDockStation east = new FlapDockStation();
FlapDockStation west = new FlapDockStation();
FlapDockStation south = new FlapDockStation();
ScreenDockStation north = new FlapDockStation();
ScreenDockStation screen = new ScreenDockStation(owner);

frontend.addRoot( screen, “screen”);
frontend.addRoot( east, “east”);
frontend.addRoot( west, “west”);
frontend.addRoot( south, “south”);
frontend.addRoot( north, “north”);
frontend.addRoot( split, “split”);

DefaultDockable defaultDockable1 = new DefaultDockable(panel, name);
frontend.addDockable(“dockable1”, defaultDockable1);
DefaultDockable defaultDockable2 = new DefaultDockable(panel, name);
frontend.addDockable(“dockable2”, defaultDockable2);
DefaultDockable defaultDockable3 = new DefaultDockable(panel, name);
frontend.addDockable(“dockable3”, defaultDockable3);

frontend.setDefaultStation(split);

east.add(defaultDockable1);
west.add(defaultDockable2);
north.add(defaultDockable3);

All dockable are being displayed in the default station. what I’m doing wrong? Could you please help?

I’m sorry, but if I execute the code below the Dockables are at the correct position (I’ve added a screenshot as proof).

Maybe you can post your full application (if it is not too big)?


import javax.swing.JFrame;

import bibliothek.gui.DockFrontend;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.FlapDockStation;
import bibliothek.gui.dock.ScreenDockStation;
import bibliothek.gui.dock.SplitDockStation;

public class Test{
	public static void main( String[] args ) throws Exception{
		JFrame frame = new JFrame();
		DockFrontend frontend = new DockFrontend( frame );
		
		SplitDockStation split = new SplitDockStation();
		FlapDockStation east = new FlapDockStation();
		FlapDockStation west = new FlapDockStation();
		FlapDockStation south = new FlapDockStation();
		FlapDockStation north = new FlapDockStation();
		ScreenDockStation screen = new ScreenDockStation( frame );

		frontend.addRoot( screen, "screen");
		frontend.addRoot( east, "east");
		frontend.addRoot( west, "west");
		frontend.addRoot( south, "south");
		frontend.addRoot( north, "north");
		frontend.addRoot( split, "split");

		DefaultDockable defaultDockable1 = new DefaultDockable( "a" );
		frontend.addDockable("dockable1", defaultDockable1);
		DefaultDockable defaultDockable2 = new DefaultDockable( "b" );
		frontend.addDockable("dockable2", defaultDockable2);
		DefaultDockable defaultDockable3 = new DefaultDockable( "c" );
		frontend.addDockable("dockable3", defaultDockable3);

		frontend.setDefaultStation(split);

		east.add(defaultDockable1);
		west.add(defaultDockable2);
		north.add(defaultDockable3);
		
		frame.add( split, BorderLayout.CENTER );
		frame.add( east.getComponent(), BorderLayout.EAST );
		frame.add( west.getComponent(), BorderLayout.WEST );
		frame.add( south.getComponent(), BorderLayout.SOUTH );
		frame.add( north.getComponent(), BorderLayout.NORTH );
		
		frame.setBounds( 20, 20, 500, 500 );
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setVisible( true );
	}
}```

Hi,

Thx for your example. It helps me.
I tried to change 2 of the defined station from FlapDockStation to StackDockStaion and SplitdockStation. Could you please check why it’s not working.
Could you please a detailed suggest a doc that can help me undertanding more how things work?

import java.awt.BorderLayout;
import javax.swing.JFrame;
import bibliothek.gui.DockFrontend;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.FlapDockStation;
import bibliothek.gui.dock.ScreenDockStation;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.StackDockStation;

public class Test {
    public static void main(String[] args) throws Exception {
        JFrame frame = new JFrame();
        DockFrontend frontend = new DockFrontend(frame);
        SplitDockStation split = new SplitDockStation();
        StackDockStation east = new StackDockStation();
        FlapDockStation west = new FlapDockStation();
        FlapDockStation south = new FlapDockStation();
        SplitDockStation north = new SplitDockStation();
        ScreenDockStation screen = new ScreenDockStation(frame);
        frontend.addRoot(screen, "screen");
        frontend.addRoot(east, "east");
        frontend.addRoot(west, "west");
        frontend.addRoot(south, "south");
        frontend.addRoot(north, "north");
        frontend.addRoot(split, "split");

        DefaultDockable defaultDockable1 = new DefaultDockable("a");
        frontend.addDockable("dockable1", defaultDockable1);
        DefaultDockable defaultDockable2 = new DefaultDockable("b");
        frontend.addDockable("dockable2", defaultDockable2);
        DefaultDockable defaultDockable3 = new DefaultDockable("c");
        frontend.addDockable("dockable3", defaultDockable3);

        frontend.setDefaultStation(split);
        east.drop(defaultDockable1);
        west.add(defaultDockable2);
        north.drop(defaultDockable3);

        frame.add(split, BorderLayout.CENTER);
        frame.add(east.getComponent(), BorderLayout.EAST);
        frame.add(west.getComponent(), BorderLayout.WEST);
        frame.add(south.getComponent(), BorderLayout.SOUTH);
        frame.add(north.getComponent(), BorderLayout.NORTH);

        frame.setBounds(20, 20, 500, 500);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}

Thx

Here the problem is, that the preferred size of SplitDockStation and StackDockStation are not calculated. Hence BorderLayout gives them a width/height of 0.

An additional panel could solve this (see code below).

As for documentation… the 2 pdf files provided with the library and the javadoc itself is everything I’ve ever written about the library. Maybe one or the other thread in this forum can be of interest, but I don’t have more material to read.

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import bibliothek.gui.DockFrontend;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.FlapDockStation;
import bibliothek.gui.dock.ScreenDockStation;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.StackDockStation;


public class Test {
    public static void main(String[] args) throws Exception {
        JFrame frame = new JFrame();
        DockFrontend frontend = new DockFrontend(frame);
        
        SplitDockStation split = new SplitDockStation();
        
        StackDockStation east = new StackDockStation();
        FlapDockStation west = new FlapDockStation();
        FlapDockStation south = new FlapDockStation();
        SplitDockStation north = new SplitDockStation();
        
        ScreenDockStation screen = new ScreenDockStation(frame);
        frontend.addRoot(screen, "screen");
        frontend.addRoot(east, "east");
        frontend.addRoot(west, "west");
        frontend.addRoot(south, "south");
        frontend.addRoot(north, "north");
        frontend.addRoot(split, "split");

        DefaultDockable defaultDockable1 = new DefaultDockable("a");
        frontend.addDockable("dockable1", defaultDockable1);
        DefaultDockable defaultDockable2 = new DefaultDockable("b");
        frontend.addDockable("dockable2", defaultDockable2);
        DefaultDockable defaultDockable3 = new DefaultDockable("c");
        frontend.addDockable("dockable3", defaultDockable3);

        frontend.setDefaultStation(split);
        east.drop(defaultDockable1);
        west.add(defaultDockable2);
        north.drop(defaultDockable3);

        frame.add(split, BorderLayout.CENTER);
        frame.add(new PrefPanel( east.getComponent() ), BorderLayout.EAST);
        frame.add(new PrefPanel( west.getComponent() ), BorderLayout.WEST);
        frame.add(new PrefPanel( south.getComponent() ), BorderLayout.SOUTH);
        frame.add(new PrefPanel( north.getComponent() ), BorderLayout.NORTH);

        frame.setBounds(20, 20, 500, 500);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
    
    private static class PrefPanel extends JPanel{
    	public PrefPanel( Component component ){
    		setLayout( new GridLayout( 1, 1 ) );
    		add( component );
    	}
    	
    	@Override
    	public Dimension getPreferredSize(){
    		Dimension result = super.getPreferredSize();
    		return new Dimension( Math.max( 40, result.width ), Math.max( 40, result.height ));
    	}
    }
}```

Hi,

I created the following structure, but I lost the resize functionality between a & b.

  1. JFrame
    JPanel
    SplitDockStation
    SplitDockStation
    DefaultDockable
    SplitDockStation
    DefaultDockable
    Panel
    a. SplitDockStation
    b. StackDockStation
    StackDockStation


import java.awt.Color;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;
import bibliothek.gui.DockFrontend;
import bibliothek.gui.DockStation;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.StackDockStation;
import bibliothek.gui.dock.control.SingleParentRemover;
import bibliothek.gui.dock.station.split.SplitDockProperty;

public class Test {
    
    public static void main( String[] args ) throws Exception{
            JFrame frame = new JFrame();
            frame.setLayout(new MigLayout("fill"));
            
            JPanel rootPanel = new JPanel();
            rootPanel.setLayout(new MigLayout("fill"));
            
            DockFrontend frontend = new DockFrontend(frame);
            
            SplitDockStation root = new SplitDockStation();
            frontend.addRoot( "root", root );
            final SplitDockStation split = new SplitDockStation();
            split.setTitleText( "Split");
            final StackDockStation stack = new StackDockStation();
            stack.setTitleText( "Stack");
            frontend.getController().setSingleParentRemover( new SingleParentRemover(){
                @Override
                protected boolean shouldTest(DockStation station){
                    return false;
                }
            });
            
            DefaultDockable a = new DefaultDockable("a");
            a.setLayout(new MigLayout("fill"));
            
            SplitDockStation childRootDockable = new SplitDockStation();
            childRootDockable.setLayout(new MigLayout("fill"));
            frontend.addRoot( "childRootDockable", childRootDockable );
            DefaultDockable aa = new DefaultDockable("aa");
            frontend.addDockable("aa", aa);
            
            childRootDockable.drop(aa);
            a.add(childRootDockable.getComponent());
            
            JPanel panel = new JPanel();
            panel.setBackground(Color.YELLOW);
            panel.setLayout(new MigLayout("fill"));
            JButton button = new JButton("Button");
            panel.add(button);
            a.add(panel, "grow");
            SplitDockStation panelSplitStation = new SplitDockStation();
            panelSplitStation.setLayout(new MigLayout("fill"));
            frontend.addRoot("panelSplitStation", panelSplitStation);
            DefaultDockable panelDockable = new DefaultDockable();
            panelDockable.setTitleText("PanelDockable");
            panelDockable.setLayout(new MigLayout("fill"));
            frontend.addDockable("panelDockable", panelDockable);
            panelSplitStation.drop(panelDockable);
            panel.add(panelSplitStation, "cell 0 0, grow");
            
            
            StackDockStation panelStackStation = new StackDockStation();
            frontend.addRoot("panelStackStation", panelStackStation);
            DefaultDockable paneStacklDockable = new DefaultDockable();
            paneStacklDockable.setTitleText("PanelStackDockable");
            paneStacklDockable.setLayout(new MigLayout("fill"));
            frontend.addDockable("panelStackDockable", paneStacklDockable);
            panelStackStation.drop(paneStacklDockable);
            panel.add(panelStackStation.getComponent(), "cell 0 0, grow");
            
            frontend.addDockable("dockable1", a);
            DefaultDockable b = new DefaultDockable("b");
            frontend.addDockable("dockable2", b);
            DefaultDockable c = new DefaultDockable("c");
            frontend.addDockable("dockable3", c);
            DefaultDockable d = new DefaultDockable("d");
            frontend.addDockable("dockable4", d);
            DefaultDockable e = new DefaultDockable("e");
            frontend.addDockable("dockable5", e);
     
            root.drop(split);
            root.drop(stack, SplitDockProperty.EAST);
     
            split.drop(a);
            split.drop(b, SplitDockProperty.EAST);
            split.drop(c, SplitDockProperty.SOUTH);
           
            stack.drop(d);
            stack.drop(e);
            
            
            rootPanel.add(root, "cell 0 0, grow");
            
            JPanel rootPanelChild = new JPanel();
            rootPanelChild.setLayout(new MigLayout("fill"));
            rootPanelChild.setBackground(Color.MAGENTA);
            
            frame.add(rootPanel, "cell 0 0, grow");
            frame.add(rootPanelChild, "cell 0 1, grow");
            
           
            frame.setBounds(20, 20, 500, 500);
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            frame.setVisible( true );
        }
}

Now I don’t exactly know which one you mean. The elements on the yellow panel? But that is an issue of the panel, not of DF?

Btw, your application revealed a bug in the framework. Thanks :slight_smile:

Hi,

I need to be able to resize panelSplitStation and panelStackStation.

I noticed that putting both station in a parent station enable the resize between panelSplitStation and panelStatckStation.
Can I do that without adding a parent root station?

Thx

As with any other java.awt.Component, boundaries are managed by the parent, not the Component itself. You could for example use a JSplitPane instead of a JPanel, or invent your own “resize-my-children-container”. The panelSplit/StackStations cannot help you in this scenario - it is not their responsibility to provide resize capabilities (neither in DF, nor in AWT/Swing).