Hi,
station.removeDockable does not work if the dockable is nested inside another.
frontend.removeDockable has the same problem.
The code below demonstrates this problem, when you run it, you’ll notice the „b“ panel still shows despite being removed. (tested in version 1.1.1)
Regards,
the Docktor
import java.awt.BorderLayout;
import java.awt.Frame;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import bibliothek.gui.DockController;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.station.split.DockableSplitDockTree;
import bibliothek.gui.dock.station.split.SplitDockTree;
public class DockRemoveProblem extends JFrame {
public DockRemoveProblem() {
// init
DockController controller = new DockController();
controller.setRootWindow(this);
SplitDockStation station = new SplitDockStation();
controller.add(station);
// create dockables
DefaultDockable da = new DefaultDockable(new JPanel(),"a");
DefaultDockable db = new DefaultDockable(new JPanel(),"b");
DefaultDockable dc = new DefaultDockable(new JLabel("c"),"c");
DefaultDockable dd = new DefaultDockable(new JLabel("d"),"d");
// set structure
DockableSplitDockTree tree = new DockableSplitDockTree();
SplitDockTree<Dockable>.Key group = tree.put(new Dockable[]{ da, db});
SplitDockTree<Dockable>.Key topTree = tree.horizontal( dc, dd, 1.0/4.0 );
SplitDockTree<Dockable>.Key root = tree.vertical( topTree, group, 0.5 );
tree.root(root);
station.dropTree(tree);
// remove db / dd
station.removeDockable(db); // this one is not removed!!!
station.removeDockable(dd);
setLayout(new BorderLayout());
add(station, BorderLayout.CENTER);
}
public static void main(String... args) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run(){
DockRemoveProblem appFrame = new DockRemoveProblem();
appFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
appFrame.setVisible(true);
}
});
}
}