add To Horizontal Border Layout - Java Swing

Java examples for Swing:Layout Manager

Description

add To Horizontal 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 addToHorizontalBorderLayout(JComponent west,
            JComponent center, JComponent east) {
        JPanel panel = new JPanel(new BorderLayout());

        if (west != null) {
            panel.add(west, BorderLayout.WEST);
        }//from w w w  .  j  a v  a  2s . c o m

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

        if (east != null) {
            panel.add(east, BorderLayout.EAST);
        }

        return panel;
    }
}

Related Tutorials