Java tutorial
//package com.java2s; import java.awt.BorderLayout; import javax.swing.JComponent; import javax.swing.JPanel; public class Main { /** * Creates a JPanel containing the component hugging the left side * @param component the component to wrap * @return a JPanel containing the component hugging the left side */ public static JPanel hugWest(JComponent component) { final JPanel result = new JPanel(new BorderLayout()); result.add(component, BorderLayout.WEST); return result; } }