Java JPanel Child packPanel(JPanel p, int width)

Here you can find the source of packPanel(JPanel p, int width)

Description

pack Panel

License

Open Source License

Declaration

public static void packPanel(JPanel p, int width) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;
import java.awt.Dimension;

import javax.swing.JPanel;

public class Main {
    public static void packPanel(JPanel p, int width) {
        int minh = 0;
        for (Component c : p.getComponents()) {
            minh += c.getMinimumSize().getHeight();
        }//from  w  w  w.  j a va  2s. c  o m

        p.setMinimumSize(new Dimension(width, minh));
        p.setMaximumSize(new Dimension(width, minh));

    }
}

Related

  1. addWidth(JPanel panel, int width)
  2. addWithPadding(JPanel parentPanel, JPanel panelToBeAdded)
  3. fillPanel(final JPanel panel, final GridBagConstraints gbc)
  4. fillPanel(JPanel panel, Component... components)
  5. getOutermostContainer(JPanel container)
  6. padPanel(Object innerPanel, JPanel outerPanel, int pad)
  7. removeComponentFromPanel(Component removeComponent, JPanel fromPanel)
  8. removePanel(JPanel parent, JPanel panel)
  9. resetControlsInAPanel(JPanel panel)