Java JComponent Size resize(JComponent component, Dimension size)

Here you can find the source of resize(JComponent component, Dimension size)

Description

resize

License

Open Source License

Declaration

private static void resize(JComponent component, Dimension size) 

Method Source Code

//package com.java2s;
/**//from  w  ww .ja va 2 s.  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 resize(JComponent component, Dimension size) {
        component.setPreferredSize(size);
        component.setMaximumSize(size);
        component.setMinimumSize(size);
    }

    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. makeSameSize(JComponent... comps)
  2. makeSameSize(JComponent[] comps)
  3. minSize(T comp, int width)
  4. paint(final Component c, Dimension size)
  5. preferredSize(JComponent component)
  6. resizeComponentWidth(JComponent currentComponent, double maxComponentWidth)
  7. restrictWindowMinimumSize(final Window wnd, final Dimension minSize)
  8. sameSize(JComponent[] components)
  9. saveComponentSize(JComponent comp, Preferences prefs, String name)