Java Swing BorderLayout makeLateralBorders(JPanel panel, Dimension reference, Border style)

Here you can find the source of makeLateralBorders(JPanel panel, Dimension reference, Border style)

Description

make Lateral Borders

License

Open Source License

Declaration

public static void makeLateralBorders(JPanel panel, Dimension reference, Border style) 

Method Source Code


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

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;

public class Main {
    public static void makeLateralBorders(JPanel panel, Dimension reference, Border style) {
        JLabel placeHolder = new JLabel("");
        placeHolder.setBorder(style);//w w  w  .  j a v a2  s . co m
        placeHolder
                .setPreferredSize(new Dimension((int) (reference.getWidth() / 16), (int) (reference.getHeight())));
        panel.add(placeHolder, BorderLayout.WEST);

        placeHolder = new JLabel("");
        placeHolder.setBorder(style);
        placeHolder
                .setPreferredSize(new Dimension((int) (reference.getWidth() / 32), (int) (reference.getHeight())));
        panel.add(placeHolder, BorderLayout.EAST);
    }
}

Related

  1. createPanel(Component comp, boolean setBorder, int borderType)
  2. createPanel(JComponent centerComponent, JComponent placedComponent, String borderLayoutConstraint)
  3. layoutCompactHorizontal(JComponent... list)
  4. layoutCompactVertical(JComponent... list)
  5. makeBorderPanel(int topMargin, int leftMargin, int bottomMargin, int rightMargin)
  6. wrapInBorderPanel(final JComponent component)
  7. wrapWithBorder(JComponent aPanel, Border aBorder)