Here you can find the source of createJScrollPane(JList list)
JScrollPane
object with the given properties.
Parameter | Description |
---|---|
list | The list of the scroll pane |
JScrollPane
object
public static JScrollPane createJScrollPane(JList list)
//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; } }