Java examples for Swing:Layout Manager
add To Horizontal Border Layout
//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; } }