Collapsed JSplitPane containing CControl throws IllegalArgumentException

Using Java 6 and DockingFrames 1.1.2 Preview 16a I have encountered an “IllegalArgumentException, size must be in the range 0.0 to 1.0” in SplitDockPathProperty.insert(SplitDockPathProperty.java:241). Each time, I have a set of DefaultSingleCDockable objects each given the same PlaceholderGrouping as is done in the “Grouping Dockables” tutorial. The content area of the control is added to a JPanel. This JPanel is then added to a JSplitPane, top or bottom, which has its oneTouchExpandable property set to true.

With both the top and bottom of the splitpane visible, all is fine. I can tear dockables off of the stack and drag them back just fine. However, when a user clicks the arrow buttons to collapse the JSplitPane completely, dragging a torn-off dockable to the location of the collapsed stack throws the exception. The shortcuts to reattach the dockable work fine (Ctrl+N or the button at the top right of the externalized dockable).

I believe this is due to the mouse event notifying the DefaultDockRelocator who in its listStationsOrdered method relies on each station’s isStationShowing method. I’m using the default SplitDockStation, and when it is the top-level station its isStationShowing method falls back on JLayeredPane’s isShowing method. This works its way up the tree of parent containers checking each with isShowing(). The collapsed panel in the JSplitPane returns true to isShowing, even if its height or width are 0, because its visibility is still set to true. This seems to create a problem in determining where to place the dropped dockable.

I have tried to create a small example that demonstrates similar behavior, but can’t seem to do so. My application is complex with many nested containers, so it could be that the complexity of the GUI is what makes this problem appear, or perhaps I am using something in dockingframes incorrectly.

As a workaround, I was able to override the isShowing method in the JPanel to which the control’s content area was added. It now also checks to ensure that the height and width are > 0. This resolves the exception and prevents the user from using drag and drop to reattach when the container is not actually visible. Using the core jar, I believe this is the behavior I observer with StackDockStation… When it was collapsed, I could not drag to reattach externalized dockables. Was it intentional to allow this behavior in the common jar?

Excellent library, by the way. It allowed me to provide clients with exactly what they were thinking of, and more. Very robust. Thank you.

Exception detectedThread: Thread[AWT-EventQueue-0,6,main]Exception: class java.lang.IllegalArgumentException, size must be in the range 0.0 to 1.0
Stack Trace: bibliothek.gui.dock.station.split.SplitDockPathProperty.insert(SplitDockPathProperty.java:241)
bibliothek.gui.dock.station.split.SplitTreePathFactory.vertical(SplitTreePathFactory.java:70)
bibliothek.gui.dock.station.split.SplitTreePathFactory.vertical(SplitTreePathFactory.java:38)
bibliothek.gui.dock.station.split.Node.submit(Node.java:787)
bibliothek.gui.dock.station.split.Root.submit(Root.java:334)
bibliothek.gui.dock.SplitDockStation.getDockablePathProperty(SplitDockStation.java:1415)
bibliothek.gui.dock.SplitDockStation.getDockablePlaceholderProperty(SplitDockStation.java:1491)
bibliothek.gui.dock.SplitDockStation.getDockableProperty(SplitDockStation.java:1324)
bibliothek.gui.dock.util.DockUtilities.getPropertyChain(DockUtilities.java:342)
bibliothek.gui.dock.common.mode.station.CSplitDockStationHandle$Normal.getLocation(CSplitDockStationHandle.java:332)
bibliothek.gui.dock.facile.mode.DefaultLocationMode.current(DefaultLocationMode.java:51)
bibliothek.gui.dock.facile.mode.DefaultLocationMode.current(DefaultLocationMode.java:42)
bibliothek.gui.dock.support.mode.ModeManager$DockableHandle.putMode(ModeManager.java:1431)
bibliothek.gui.dock.support.mode.ModeManager.refresh(ModeManager.java:776)
bibliothek.gui.dock.facile.mode.LocationModeManager$RegisterListener.registerUnstalled(LocationModeManager.java:703)
bibliothek.gui.dock.control.DockRegister.fireUnstalled(DockRegister.java:497)
bibliothek.gui.dock.control.DockRegister.setStalled(DockRegister.java:524)
bibliothek.gui.dock.control.relocator.DefaultDockRelocator.executeOperation(DefaultDockRelocator.java:263)
bibliothek.gui.dock.control.relocator.DefaultDockRelocator.dragMouseReleased(DefaultDockRelocator.java:875)
bibliothek.gui.dock.control.relocator.DefaultDockRelocator.dragMouseReleased(DefaultDockRelocator.java:775)
bibliothek.gui.dock.control.relocator.DefaultDockRelocator$MouseRepresentativeListener.mouseReleased(DefaultDockRelocator.java:1165)
bibliothek.gui.dock.control.relocator.DefaultDockRelocator$GlobalMouseReleaseListener.mouseReleased(DefaultDockRelocator.java:1202)
bibliothek.gui.dock.control.DefaultGlobalMouseDispatcher.dispatch(DefaultGlobalMouseDispatcher.java:116)
bibliothek.gui.dock.control.DefaultGlobalMouseDispatcher$3.eventDispatched(DefaultGlobalMouseDispatcher.java:235)
java.awt.Toolkit$SelectiveAWTEventListener.eventDispatched(Toolkit.java:2353)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2245)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2244)
java.awt.Toolkit.notifyAWTEventListeners(Toolkit.java:2203)
java.awt.Component.dispatchEventImpl(Component.java:4528)
java.awt.Container.dispatchEventImpl(Container.java:2099)
java.awt.Component.dispatchEvent(Component.java:4460)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
java.awt.Container.dispatchEventImpl(Container.java:2085)
java.awt.Window.dispatchEventImpl(Window.java:2475)
java.awt.Component.dispatchEvent(Component.java:4460)
java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
java.awt.EventDispatchThread.run(EventDispatchThread.java:122)




Exception detectedThread: Thread[AWT-EventQueue-0,6,main]Exception: class java.lang.IllegalArgumentException, size must be in the range 0.0 to 1.0
Stack Trace: bibliothek.gui.dock.station.split.SplitDockPathProperty.insert(SplitDockPathProperty.java:241)
bibliothek.gui.dock.station.split.SplitTreePathFactory.vertical(SplitTreePathFactory.java:70)
bibliothek.gui.dock.station.split.SplitTreePathFactory.vertical(SplitTreePathFactory.java:38)
bibliothek.gui.dock.station.split.Node.submit(Node.java:787)
bibliothek.gui.dock.station.split.Root.submit(Root.java:334)
bibliothek.gui.dock.SplitDockStation.getDockablePathProperty(SplitDockStation.java:1415)
bibliothek.gui.dock.SplitDockStation.getDockablePlaceholderProperty(SplitDockStation.java:1491)
bibliothek.gui.dock.SplitDockStation.getDockableProperty(SplitDockStation.java:1324)
bibliothek.gui.dock.util.DockUtilities.getPropertyChain(DockUtilities.java:342)
bibliothek.gui.dock.common.mode.station.CSplitDockStationHandle$Normal.getCLocation(CSplitDockStationHandle.java:394)
bibliothek.gui.dock.common.mode.CNormalMode.getCLocation(CNormalMode.java:82)
bibliothek.gui.dock.common.mode.CLocationModeManager.getLocation(CLocationModeManager.java:324)
bibliothek.gui.dock.common.intern.AbstractCDockable.getBaseLocation(AbstractCDockable.java:435)
bibliothek.gui.dock.common.intern.CDockableLocationListenerManager.checkNow(CDockableLocationListenerManager.java:107)
bibliothek.gui.dock.common.intern.CDockableLocationListenerManager.access$200(CDockableLocationListenerManager.java:46)
bibliothek.gui.dock.common.intern.CDockableLocationListenerManager$2.run(CDockableLocationListenerManager.java:99)
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

You are describing a use case I never thought of, it is not intentional that „core“ and „common“ behave differently. Well I guess drag and dropping something to an area that has a size of 0 is a bit strange and should not be allowed, so I’ll add some code to prevent stations of size 0 to be targets. Basically I’ll just copy your fix :wink: (I should be able to get the fix out this weekend).

The code that prevents stations from being targets of drag and drop operations if they have size 0 is now part of 1.1.2p17 which is available on the website.

I backed out my workaround and took your new jars, all works as expected. Thanks!