Returns a JPanel with the specified component nested inside it - Java Swing

Java examples for Swing:JPanel

Description

Returns a JPanel with the specified component nested inside it

Demo Code


//package com.java2s;

import javax.swing.JComponent;

import javax.swing.JPanel;

public class Main {
    /**//from w  w w.ja  v a 2  s .c  om
     * Returns a JPanel with the specified component nested inside it
     * @param toNest The component to nest in a new JPanel
     * @return A new JPanel with the component added inside it
     */
    public static JPanel nestInPanel(JComponent toNest) {
        JPanel container = new JPanel();
        container.add(toNest);
        return container;
    }
}

Related Tutorials