Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the slow scroll speed on a JScrollPane?

I am adding a JPanel in a JScrollPane in my project.

All is working fine, but there is one problem about mouse scroll using the mouse-Wheel in JPanel. It's speed is very slow on scrolling. How to make it faster?

My code is :

JPanel panel = new JPanel();

panel.setLayout(new BorderLayout());
objCheckBoxList = new CheckBoxList();
BaseTreeExplorer node = (BaseTreeExplorer)projectMain.objCommon.tree.getLastSelectedPathComponent();
if (node.getObject() != null) {
    cmbList.setSelectedItem(node.getParent().toString());
} else {
    if (node.toString().equalsIgnoreCase("List of attributes")) {
        cmbList.setSelectedIndex(0);
    } else {
        cmbList.setSelectedItem(node.toString());
    }
}

panel.add(objCheckBoxList);

JScrollPane myScrollPanel = new JScrollPane(panel);

myScrollPanel.setPreferredSize(new Dimension(200, 200));
myScrollPanel.setBorder(BorderFactory.createTitledBorder("Attribute List"));
like image 957
Ronak Avatar asked Apr 12 '12 07:04

Ronak


1 Answers

You can set your scrolling speed with this line of code

myJScrollPane.getVerticalScrollBar().setUnitIncrement(16);
Here is details.
like image 133
mbaydar Avatar answered Sep 20 '22 07:09

mbaydar