Example usage for javax.swing JScrollBar JScrollBar

List of usage examples for javax.swing JScrollBar JScrollBar

Introduction

In this page you can find the example usage for javax.swing JScrollBar JScrollBar.

Prototype

public JScrollBar(int orientation) 

Source Link

Document

Creates a scrollbar with the specified orientation and the following initial values:
 minimum = 0 maximum = 100 value = 0 extent = 10 

Usage

From source file:org.yccheok.jstock.gui.AjaxAutoCompleteJComboBox.java

private void adjustScrollBar() {
    final int max_search = 8;
    // i < max_search is just a safe guard when getAccessibleChildrenCount
    // returns an arbitary large number. 8 is magic number
    JPopupMenu popup = null;//  w  ww. j a v  a 2  s . c om
    for (int i = 0, count = this.getUI().getAccessibleChildrenCount(this); i < count && i < max_search; i++) {
        Object o = this.getUI().getAccessibleChild(this, i);
        if (o instanceof JPopupMenu) {
            popup = (JPopupMenu) o;
            break;
        }
    }
    if (popup == null) {
        return;
    }
    JScrollPane scrollPane = null;
    for (int i = 0, count = popup.getComponentCount(); i < count && i < max_search; i++) {
        Component c = popup.getComponent(i);
        if (c instanceof JScrollPane) {
            scrollPane = (JScrollPane) c;
            break;
        }
    }
    if (scrollPane == null) {
        return;
    }
    scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}