Java tutorial
//package com.java2s; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; public class Main { /** * @return a JPanel containing a label with the specified String as its text, and the component. */ public static JPanel labelComponent(JComponent c, String s) { JPanel panel = new JPanel(); panel.add(new JLabel(s)); panel.add(c); return panel; } }