Java Swing BorderLayout createPanel(Component comp, boolean setBorder, int borderType)

Here you can find the source of createPanel(Component comp, boolean setBorder, int borderType)

Description

create Panel

License

Apache License

Declaration

public static JPanel createPanel(Component comp, boolean setBorder, int borderType) 

Method Source Code

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

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;

import javax.swing.BorderFactory;

import javax.swing.JComponent;

import javax.swing.JPanel;

import javax.swing.border.Border;

import javax.swing.border.LineBorder;

public class Main {
    public static final int RAISED_BORDER = 0;
    public static final int LOWERED_BORDER = 1;
    public static final int LINE_BORDER = 2;

    public static JPanel createPanel(Component comp, boolean setBorder) {
        return createPanel(comp, setBorder, RAISED_BORDER);
    }/*from w  ww . ja  v a 2s  .com*/

    public static JPanel createPanel(Component comp, boolean setBorder, int borderType) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(comp, BorderLayout.CENTER);
        if (setBorder)
            setBorder(panel, borderType);
        // setCompSize(labelPanel, wt, ht, 1);
        return panel;
    }

    public static void setBorder(JComponent comp) {
        setBorder(comp, RAISED_BORDER);
    }

    public static void setBorder(JComponent comp, int borderType) {
        Border border = BorderFactory.createRaisedBevelBorder();
        if (borderType == LOWERED_BORDER)
            border = BorderFactory.createLoweredBevelBorder();
        else if (borderType == LINE_BORDER)
            border = new LineBorder(Color.BLACK);
        comp.setBorder(border);
    }
}

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. createBox(Border border, Component center, Component north)
  6. createPanel(JComponent centerComponent, JComponent placedComponent, String borderLayoutConstraint)
  7. layoutCompactHorizontal(JComponent... list)
  8. layoutCompactVertical(JComponent... list)
  9. makeBorderPanel(int topMargin, int leftMargin, int bottomMargin, int rightMargin)