add To Vertical Border Layout - Java Swing

Java examples for Swing:Layout Manager

Description

add To Vertical Border Layout

Demo Code


//package com.java2s;
import java.awt.BorderLayout;

import javax.swing.JComponent;
import javax.swing.JPanel;

public class Main {
    public static JPanel addToVerticalBorderLayout(JComponent north,
            JComponent center, JComponent south) {
        JPanel panel = new JPanel(new BorderLayout());

        if (north != null) {
            panel.add(north, BorderLayout.NORTH);
        }/*from  w ww . j a  v a 2 s.  c om*/

        if (center != null) {
            panel.add(center, BorderLayout.CENTER);
        }

        if (south != null) {
            panel.add(south, BorderLayout.SOUTH);
        }

        return panel;
    }
}

Related Tutorials