Java JPanel Create createJPanel(String name, LayoutManager lm, ComponentListener cl)

Here you can find the source of createJPanel(String name, LayoutManager lm, ComponentListener cl)

Description

Auxiliar method for creating a named JPanel object.

License

Open Source License

Parameter

Parameter Description
name JPanel name.
lm Panel LayoutManager
cl A ComponentListner for handling events

Return

The named JPanel.

Declaration

public static JPanel createJPanel(String name, LayoutManager lm, ComponentListener cl) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.LayoutManager;

import java.awt.event.ComponentListener;

import javax.swing.JPanel;

public class Main {
    /**/* ww  w.j  a v  a2  s.co m*/
     * Auxiliar method for creating a named JPanel object.
     * 
     * @param name JPanel name.
     * @param lm Panel LayoutManager
     * @param cl A ComponentListner for handling events
     * @return The named JPanel.
     */
    public static JPanel createJPanel(String name, LayoutManager lm, ComponentListener cl) {

        JPanel jp;

        if (lm != null) {
            jp = new JPanel(lm);
        } else {
            jp = new JPanel();
        }

        jp.setName(name);
        jp.addComponentListener(cl);

        return jp;

    }

    /**
     * Auxiliar method for creating a named JPanel object.
     * 
     * @param name JPanel name.
     * @param cl A ComponentListner for handling events
     * @return The named JPanel.
     */
    public static JPanel createJPanel(String name, ComponentListener cl) {

        return createJPanel(name, null, cl);

    }
}

Related

  1. createBlankColorPanel(int height, int width, Color bkColor)
  2. createCenteredWindow(String title, Dimension size, JPanel panel, boolean exitOnClose)
  3. createFlowJPanelLeft(JComponent parent, int alignment)
  4. createGridedJPanel(JComponent parent, int columns)
  5. createJPanel()
  6. createPaletteJPanel(String title)
  7. createStandardJPanel()
  8. createVerticalBoxJPanel(JComponent parent)
  9. initPanel(Color color)