Java JComponent Size setMaximumSize(Dimension maxComponentSize, JComponent component)

Here you can find the source of setMaximumSize(Dimension maxComponentSize, JComponent component)

Description

set Maximum Size

License

Open Source License

Declaration

private static void setMaximumSize(Dimension maxComponentSize, JComponent component) 

Method Source Code

//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());
    }
}

Related

  1. setComponentSize(JComponent comp, int width, int height)
  2. setFixedSize(JComponent component, Dimension size)
  3. setFixedSize(JComponent component, Dimension size)
  4. setFixedSize(JComponent component, int width, int height)
  5. setMaximumSize(Dimension d, JComponent... components)
  6. setMaxPreferredSize(JComponent comp)
  7. setMinimumSize(JComponent component, int numChars)
  8. setPreferredSize(JComponent comp, int height, int width)
  9. setSize(Dimension size, JComponent[] components)