Java JComponent Size autoFitResize(final JLayeredPane pane, final Component... comps)

Here you can find the source of autoFitResize(final JLayeredPane pane, final Component... comps)

Description

auto Fit Resize

License

LGPL

Declaration

public static void autoFitResize(final JLayeredPane pane, final Component... comps) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.awt.Component;

import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

import javax.swing.JLayeredPane;

public class Main {

    public static void autoFitResize(final JLayeredPane pane, final Component... comps) {
        pane.addComponentListener(new ComponentAdapter() {
            @Override// ww w. j a  va2s  .c om
            public void componentResized(ComponentEvent e) {
                for (Component comp : comps) {
                    comp.setBounds(0, 0, pane.getWidth(), pane.getHeight());
                }
                pane.revalidate();
                pane.repaint();
            }
        });
    }
}

Related

  1. addWithSize(Component c, int width, int height)
  2. adjustWindowToMinimumSize(final Window window)
  3. changeSize(JComponent comp, float newSize)
  4. contentSize(final Component component)
  5. createDoubleSpinner(final double value, final double rangeMinimum, final double rangeMaximum, final double stepSize, final double bigStepSize, final String formatPattern)
  6. differsSize(AttributeSet style, AttributeSet base)