Java Swing Border createJScrollPane(Component component, Rectangle bounds, Color backgroundColor, boolean noBorder, boolean visible)

Here you can find the source of createJScrollPane(Component component, Rectangle bounds, Color backgroundColor, boolean noBorder, boolean visible)

Description

Creates a new JScrollPane object with the given properties.

License

Open Source License

Parameter

Parameter Description
component The component of the scroll pane
bounds The dimension of the component
backgroundColor The color of the background
noBorder if true then the scroll pane is without border otherwise the scroll pane will have also a border
visible if true then the scroll pane will be visible otherwise the scroll pane will be invisible

Return

A JScrollPane object

Declaration

public static JScrollPane createJScrollPane(Component component, Rectangle bounds, Color backgroundColor,
        boolean noBorder, boolean visible) 

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  . c o  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. compareTabOrder(Component a, Component b)
  2. copy(final Border border)
  3. createCompoundBorder(Border... borders)
  4. createDebugBorder(JComponent c, Color color)
  5. createFormSectionBorder(Color color, String title)
  6. createRightBorder(int size, Color color)
  7. createRoundedEmptyBorder(final int top, final int left, final int bottom, final int right, final int arc, final Color color)
  8. createTitledBorder(Color color, String name)
  9. createVerticalBox(Border border, Component... comps)