Java JScrollPane Create makeScrollPane(Component comp)

Here you can find the source of makeScrollPane(Component comp)

Description

Create a scroll panel that sets its preferred size to its minimum size.

License

Apache License

Parameter

Parameter Description
comp the component which should be placed inside the scroll pane

Return

a JScrollPane containing the specified component

Declaration

public static JScrollPane makeScrollPane(Component comp) 

Method Source Code

//package com.java2s;
/*/*from   w w  w  .  ja v a  2s . c om*/
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

import java.awt.Component;

import javax.swing.JScrollPane;

public class Main {
    /**
     * Create a scroll panel that sets its preferred size to its minimum size.
     * Explicitly for scroll panes that live inside other scroll panes, or
     * within containers that stretch components to fill the area they exist in.
     * Use this for any component you would put in a scroll pane (such as
     * TextAreas, tables, JLists, etc). It is here for convenience and to avoid
     * duplicate code. JMeter displays best if you follow this custom.
     *
     * @param comp
     *            the component which should be placed inside the scroll pane
     * @return a JScrollPane containing the specified component
     */
    public static JScrollPane makeScrollPane(Component comp) {
        JScrollPane pane = new JScrollPane(comp);
        pane.setPreferredSize(pane.getMinimumSize());
        return pane;
    }
}

Related

  1. getScrollPane(final Component component)
  2. getScrollPaneAncestor(Component c)
  3. getScrollPaneViewComponent(JComponent component)
  4. makeScrollable(JComponent c)
  5. makeScrollPane(Component c, int xdim, int ydim)
  6. makeScrollPane(Component comp)
  7. wrapScroll(Component component)
  8. wrapScrollPane(Component component)