Freeze if getPreferredSize() returns Dimension(Integer.MAX, Integer.MAX)

If the component of an DefaultSingleCDockable has a preferred size of java.awt.Dimension[width=2147483647,height=2147483647] Docking Frames 1.1.0.7e (RC1) freezes when the dockable gets externalized.

I tried other preferred sizes:

  • 3000x3000 still works, the external docking window is visible and has that size (quite amazing).
  • 20000x20000 fails with an java.lang.OutOfMemoryError: Java heap space exception

I suggest the maximal external docking window size should be limited to the maximum desktop size (of all monitors available).

Example:
public static DefaultSingleCDockable createDockable()
{
JPanel panel= new JPanel();
panel.setPreferredSize(Integer.MAX, Integer.MAX);

DefaultSingleCDockable result = new DefaultSingleCDockable( “bla” );
result.add(panel);
return result;
}

Does this also happen when die large component is not contained directly in the DefaultSingleCDockable? For example, when there is a
DefaultSingleCDockable containing a JScrollpane containing a (large) JPanel
then the JPanel could in fact be larger than the Screen (because it could simply be scrolled…).

Also note that in some places, AWT and Swing at least implicitly assume that a component will never be larger than 32767 pixels: The default getMaximumSize() of ‘Component’ returns “new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)” - a PreferredSize that is larger than the MaximumSize would not make sense, and I could imagine that some LayoutManagers could be confused when the PreferredSize is larger than the MaximumSize …

A limit would not be a bad idea, but handling multi-screen may not be easy. I’ll keep it on the todo-list, but for now I suggest you return a more „reasonable“ preferred size :wink: