Java JList Create createJScrollPane(JList list)

Here you can find the source of createJScrollPane(JList list)

Description

Creates a new JScrollPane object with the given properties.

License

Open Source License

Parameter

Parameter Description
list The list of the scroll pane

Return

A JScrollPane object

Declaration

public static JScrollPane createJScrollPane(JList list) 

Method Source Code


//package com.java2s;
import java.awt.Color;
import java.awt.Component;

import java.awt.Rectangle;

import javax.swing.JList;

import javax.swing.JScrollPane;

public class Main {
    /**//from w  w  w  . j av  a 2 s  .  co  m
     * Creates a new <code>JScrollPane</code> object with the given properties.
     *
     * @param component The component of the scroll pane
     * @param bounds The dimension of the component
     * @param backgroundColor The color of the background
     * @param noBorder if true then the scroll pane is without border otherwise
     * the scroll pane will have also a border
     * @param visible if true then the scroll pane will be visible otherwise the
     * scroll pane will be invisible
     * @return A <code>JScrollPane</code> object
     */
    public static JScrollPane createJScrollPane(Component component, Rectangle bounds, Color backgroundColor,
            boolean noBorder, boolean visible) {
        JScrollPane pane = new JScrollPane();
        if (bounds != null) {
            pane.setBounds(bounds);
        }
        pane.setBackground(backgroundColor);
        pane.setViewportView(component);
        if (noBorder) {
            pane.setBorder(null);
        }
        if (!visible) {
            pane.setVisible(false);
        }
        return pane;
    }

    /**
     * Creates a new <code>JScrollPane</code> object with the given properties.
     *
     * @param list The list of the scroll pane
     * @return A <code>JScrollPane</code> object
     */
    public static JScrollPane createJScrollPane(JList list) {
        JScrollPane jScrollPane = new JScrollPane();
        jScrollPane.setViewportView(list);
        jScrollPane.setAutoscrolls(true);
        return jScrollPane;
    }
}

Related

  1. createList(JList aListComponent, boolean createQuotes)
  2. createListPane(JList list, String text)