Dimension (Container container) { Component component = getComponent(container); return getSize(container, component != null ? component.getMaximumSize() : new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); }