Here is the code I promised.
Just using a second CGrid could help:
import javax.swing.JFrame;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.CWorkingArea;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
public class TooltipExample extends JFrame {
public static void main( String[] args ) {
TooltipExample example = new TooltipExample();
example.setBounds( 100, 100, 800, 800 );
example.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
example.setVisible( true );
}
private CControl control;
public TooltipExample() {
setTitle( "I am a dialog" );
control = new CControl( this );
add( control.getContentArea() );
CWorkingArea workingArea = control.createWorkingArea( "work" );
CGrid grid = new CGrid( control );
grid.add( 0, 0, 20, 100, new DefaultSingleCDockable( "outline", "Outline" ) );
grid.add( 20, 0, 80, 100, workingArea );
control.getContentArea().deploy( grid );
CGrid work = new CGrid( control );
work.add( 0, 0, 30, 30, new DefaultSingleCDockable( "details1", "Details 1" ) );
work.add( 0, 30, 30, 30, new DefaultSingleCDockable( "details2", "Details 2" ) );
work.add( 0, 60, 30, 30, new DefaultSingleCDockable( "details3", "Details 3" ) );
workingArea.deploy( work );
}
}
A solution that would enable you to switch between “simple” and “detailed” view at any time can be built with the help of perspectives:
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.SingleCDockable;
import bibliothek.gui.dock.common.SingleCDockableFactory;
import bibliothek.gui.dock.common.perspective.CGridPerspective;
import bibliothek.gui.dock.common.perspective.CPerspective;
import bibliothek.gui.dock.common.perspective.CWorkingPerspective;
import bibliothek.gui.dock.common.perspective.SingleCDockablePerspective;
public class TooltipExample extends JFrame {
public static void main( String[] args ) {
TooltipExample example = new TooltipExample();
example.setBounds( 100, 100, 800, 800 );
example.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
example.setVisible( true );
}
private CControl control;
public TooltipExample() {
setTitle( "I am a dialog" );
control = new CControl( this );
add( control.getContentArea() );
saveDetailed();
saveSimple();
control.addSingleDockableFactory(
id -> id.startsWith( "details" ) || id.equals( "outline" ),
id -> buildDockable(id) );
control.addSingleDockableFactory(
id -> id.equals( "work" ),
id -> control.createWorkingArea( id ) );
addMenu();
}
private void addMenu() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu( "Layout" );
menuBar.add( menu );
JMenuItem simple = new JMenuItem( "Simple" );
simple.addActionListener( e -> switchToSimpleView() );
JMenuItem details = new JMenuItem( "Details" );
details.addActionListener( e -> switchToDetailedView() );
menu.add( simple );
menu.add( details );
setJMenuBar( menuBar );
}
private SingleCDockable buildDockable(String id){
DefaultSingleCDockable dockable = new DefaultSingleCDockable( id, id.substring( 0, 1 ).toUpperCase() + id.substring( 1 ) );
dockable.add( new JScrollPane( new JTextArea() ) );
return dockable;
}
private void switchToSimpleView() {
control.load( "simple" );
}
private void saveSimple() {
CPerspective perspective = control.getPerspectives().createEmptyPerspective();
CWorkingPerspective workArea = new CWorkingPerspective( "work" );
workArea.gridAdd( 0, 0, 100, 100, new SingleCDockablePerspective( "details1" ) );
workArea.gridDeploy();
CGridPerspective center = perspective.getContentArea().getCenter();
center.gridAdd( 0, 0, 20, 100, new SingleCDockablePerspective( "outline" ) );
center.gridAdd( 20, 0, 80, 100, workArea );
center.gridDeploy();
control.getPerspectives().setPerspective( "simple", perspective, true );
}
private void switchToDetailedView() {
control.load( "details" );
}
private void saveDetailed() {
CPerspective perspective = control.getPerspectives().createEmptyPerspective();
CWorkingPerspective workArea = new CWorkingPerspective( "work" );
workArea.gridAdd( 0, 0, 100, 30, new SingleCDockablePerspective( "details1" ) );
workArea.gridAdd( 0, 30, 100, 30, new SingleCDockablePerspective( "details2" ) );
workArea.gridAdd( 0, 60, 100, 30, new SingleCDockablePerspective( "details3" ) );
workArea.gridDeploy();
CGridPerspective center = perspective.getContentArea().getCenter();
center.gridAdd( 0, 0, 20, 100, new SingleCDockablePerspective( "outline" ) );
center.gridAdd( 20, 0, 80, 100, workArea );
center.gridDeploy();
control.getPerspectives().setPerspective( "details", perspective, true );
}
}