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);
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);
}
}
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 ));
}
}
}```
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?
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).