If you want to limit only one dimension then just do not limit the other:
component.setMaximumSize( new Dimension( Integer.MAX_VALUE, requiredMaxHeight ) );
If you want to limit only one dimension then just do not limit the other:
component.setMaximumSize( new Dimension( Integer.MAX_VALUE, requiredMaxHeight ) );