Here you can find the source of setMaximumSize(Dimension maxComponentSize, JComponent component)
private static void setMaximumSize(Dimension maxComponentSize, JComponent component)
//package com.java2s; /**//from ww w .ja va 2s . c o m * Copyright (c) 2016, Lindsay Bradford and other Contributors. * All rights reserved. * * This program and the accompanying materials are made available * under the terms of the BSD 3-Clause licence which accompanies * this distribution, and is available at * http://opensource.org/licenses/BSD-3-Clause */ import java.awt.*; import javax.swing.*; public class Main { private static void setMaximumSize(Dimension maxComponentSize, JComponent component) { final Dimension componentSize = component.getPreferredSize(); maxComponentSize.width = Math.max(maxComponentSize.width, (int) componentSize.getWidth()); maxComponentSize.height = Math.max(maxComponentSize.height, (int) componentSize.getHeight()); } }