Hi Beni
I am creating a layout of dockables using SplitDockGrid. However when I hide and then show a component, it’s position seems to be inaccurate.
In the code sample below. first run it with line 42 commented out, and you will notice that the “RE” dockable appears below the “GT” dockable. This is the way it should be. Now uncomment the line we had commented out earlier (this causes all dockables except “GT” to be hidden followed by dockable “RE” being shown), and run it again. You will notice that “RE” now appears on the top of “GT”.
Is this a bug by any chance? Is there any way to fix this?
–
Thanks
Parag
import java.util.Map;
import java.util.Set;
import javax.swing.JFrame;
import bibliothek.gui.DockFrontend;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.station.split.SplitDockGrid;
public class DockingGridFillIssue
{
private static DockFrontend frontend;
private static Map<String, Dockable> dockables =
new HashMap<String, Dockable>();
public static void main(String args[])
{
SplitDockGrid splitDockGrid = new SplitDockGrid();
splitDockGrid.addDockable(0, 0, 3, 10, getDockable("FP"));
splitDockGrid.addDockable(0, 0, 3, 10, getDockable("MP"));
splitDockGrid.addDockable(0, 0, 3, 10, getDockable("MGP"));
splitDockGrid.addDockable(0, 0, 3, 10, getDockable("PIP"));
splitDockGrid.addDockable(3, 0, 5, 8, getDockable("GT"));
splitDockGrid.addDockable(3, 8, 7, 2, getDockable("RE"));
splitDockGrid.addDockable(8, 0, 2, 8, getDockable("CP"));
frontend = new DockFrontend();
SplitDockStation station = new SplitDockStation();
frontend.addRoot(station, "rootDockingStation");
station.dropTree(splitDockGrid.toTree());
JFrame frame = new JFrame();
frame.add(station.getComponent());
frame.setBounds(10, 30, 600, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
hideAndShowDockables();
}
private static void hideAndShowDockables()
{
//hide all dockables except "GT"
Set<String> keys = dockables.keySet();
for(String key : keys)
{
if(!"GT".equals(key))
{
frontend.hide(dockables.get(key));
}
}
//show "RE"
frontend.show(dockables.get("RE"));
}
private static Dockable getDockable(String title)
{
DefaultDockable dockable = new DefaultDockable(title);
dockables.put(title, dockable);
return dockable;
}
}