Java Swing BorderLayout createBox(Border border, Component center, Component north)

Here you can find the source of createBox(Border border, Component center, Component north)

Description

create Box

License

Open Source License

Declaration

public static JPanel createBox(Border border, Component center, Component north) 

Method Source Code


//package com.java2s;
/*//w ww  . j a v  a 2  s  .  co m
 * Spirit, a study/biosample management tool for research.
 * Copyright (C) 2018 Idorsia Pharmaceuticals Ltd., Hegenheimermattweg 91,
 * CH-4123 Allschwil, Switzerland.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 * @author Joel Freyss
 */

import java.awt.BorderLayout;

import java.awt.Component;

import javax.swing.JPanel;

import javax.swing.border.Border;

public class Main {
    public static JPanel createBox(Component center, Component north, Component south) {
        return createBox(null, center, north, south, null, null);
    }

    public static JPanel createBox(Component center, Component north) {
        return createBox(null, center, north, null, null, null);
    }

    public static JPanel createBox(Border border, Component center, Component north) {
        return createBox(border, center, north, null, null, null);
    }

    public static JPanel createBox(Border border, Component center, Component north, Component south) {
        return createBox(border, center, north, south, null, null);
    }

    public static JPanel createBox(Border border, Component center) {
        return createBox(border, center, null, null, null, null);
    }

    public static JPanel createBox(Component center, Component north, Component south, Component west,
            Component east) {
        return createBox(null, center, north, south, west, east);
    }

    public static JPanel createBox(Border border, Component center, Component north, Component south,
            Component west, Component east) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.setOpaque(false);
        if (center != null)
            panel.add(BorderLayout.CENTER, center);
        if (north != null)
            panel.add(BorderLayout.NORTH, north);
        if (south != null)
            panel.add(BorderLayout.SOUTH, south);
        if (west != null)
            panel.add(BorderLayout.WEST, west);
        if (east != null)
            panel.add(BorderLayout.EAST, east);
        if (border != null)
            panel.setBorder(border);
        return panel;
    }
}

Related

  1. addBorders(Component content)
  2. addToPanel(JPanel panel, JComponent centerComponent, JComponent arrangedComponent, String borderLayoutConstraint)
  3. addToVerticalBorderLayout(JComponent north, JComponent center, JComponent south)
  4. createBorderLayoutPane(Object... args)
  5. createPanel(Component comp, boolean setBorder, int borderType)
  6. createPanel(JComponent centerComponent, JComponent placedComponent, String borderLayoutConstraint)
  7. layoutCompactHorizontal(JComponent... list)
  8. layoutCompactVertical(JComponent... list)