Adding sliders between stations

Hello,

I need to add sliders between different stations. Any help?

Thank you

Actually I have no clue what you want to do.

What kind of stations? How should the GUI look at the end? What does your code already?

Hi Beni,

In my sample, I created 2 SplitDockStation and I put a DefaultDockable in each station.
I need to be able to resize those 2 DefaultDockable.

Below is the code :


import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;

import net.miginfocom.swing.MigLayout;
import bibliothek.extension.gui.dock.theme.FlatTheme;
import bibliothek.gui.DockController;
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.station.stack.StackDockComponent;
import bibliothek.gui.dock.station.stack.StackDockComponentFactory;
import bibliothek.gui.dock.themes.BasicTheme;
import bibliothek.gui.dock.themes.basic.BasicStackDockComponent;

public class Demo {
    public static void main(String[] args) {
        // create a frame
        JFrame frame = new JFrame("Demo");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setSize(600, 500);
        frame.setLayout(new MigLayout("fill"));

        JPanel topRootPanel = new JPanel();
        topRootPanel.setLayout(new MigLayout("fill"));
        DockController dockController = new DockController();
        DockFrontend frontend = new DockFrontend(dockController);

        SplitDockStation east = new SplitDockStation();
        SplitDockStation west = new SplitDockStation();

        frontend.addRoot(east, "east");
        frontend.addRoot(west, "west");
        frontend.setDefaultHideable(true);

        topRootPanel.add(east.getComponent(), "grow, cell 0 0");
        topRootPanel.add(west.getComponent(), "grow, cell 0 1");
        addPanel(frontend, east, Color.GREEN);
        addPanel(frontend, west, Color.YELLOW);

        frame.getContentPane().add(topRootPanel, "grow");
        frame.setVisible(true);
    }

    public static void addPanel(DockFrontend frontend, DockStation station, Color color) {
        JPanel panel = new JPanel();
        panel.setBackground(color);
        panel.setOpaque(true);
        String name = color.toString();
        JLabel label = new JLabel(name);
        panel.add(label, "grow");
        DefaultDockable dockable = new DefaultDockable(panel, name);
        station.drop(dockable);
        frontend.add(dockable, name + station.getClass());
        frontend.setHideable(dockable, true);
    }
}

Thank you

You could put them on a JSplitPane or on yet another SplitDockStation (which would not be my preferred solution).

But why do you use/need two SplitDockStation’s at all? One station would create the same layout including the slider.

Hi Beni,

Thanks for your previous reply.

What I can I do in case I have 2 different type of stations, a SplitDockStation and StackDockstation?
Could you please give me an example how I can implement this case and to be able to resize stations?

Thank you

How about something like this? The new SingleParentRemover prevents the split and stack-stations of beeing automatically removed. A few instances of a DockAcceptance could prevent the stations from jumping into each other, or from Dockables that are used outside split or stack.


import javax.swing.JFrame;

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();
		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 
				station != stack &&
				   station != split &&
				   super.shouldTest( station );
			}
		});

		DefaultDockable a = new DefaultDockable( "a" );
		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 );
		
		frame.add( root, BorderLayout.CENTER );
		
		frame.setBounds( 20, 20, 500, 500 );
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setVisible( true );
	}
}