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 top side * @param component the component to wrap * @return a JPanel containing the component hugging the top side */ public static JPanel hugNorth(JComponent component) { final JPanel result = new JPanel(new BorderLayout()); result.add(component, BorderLayout.NORTH); return result; } }