Here you can find the source of wrapInPanel(final JComponent comp, final LayoutManager lm)
Parameter | Description |
---|---|
comp | component to be wrapped |
lm | layout manager to use for the panel |
public static JPanel wrapInPanel(final JComponent comp, final LayoutManager lm)
//package com.java2s; //License from project: Apache License import java.awt.FlowLayout; import java.awt.LayoutManager; import javax.swing.JComponent; import javax.swing.JPanel; public class Main { /**//from w ww. j a va 2 s. c o m * Wraps a component in a {@link JPanel} with {@link FlowLayout}, and returns it. * * @param comp component to be wrapped * @return a {@link JPanel} wrapping the specified component * * @see #wrapInPanel(JComponent, LayoutManager) */ public static JPanel wrapInPanel(final JComponent comp) { return wrapInPanel(comp, new FlowLayout()); } /** * Wraps a component in a {@link JPanel} with the specified layout manager, and returns it. * * @param comp component to be wrapped * @param lm layout manager to use for the panel * @return a {@link JPanel} wrapping the specified component * * @see #wrapInPanel(JComponent) */ public static JPanel wrapInPanel(final JComponent comp, final LayoutManager lm) { final JPanel p = new JPanel(lm); p.add(comp); return p; } }