# Scroll bar is slow

**URL:** <https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043>\
**Category:** Ignition\
**Created:** [August 22, 2012, 5:57pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043 "2012-08-22T17:57:52Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [August 22, 2012, 5:57pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/1 "2012-08-22T17:57:52Z")

</div>

I have noticed if I make window’s height very tall so there is a scroll bar on the right when a user uses the mouse wheel to scroll the scroll bar barely moves. Is there a way to speed up the mouse wheel scroll on tall windows?

Thank you,

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [August 22, 2012, 10:54pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/2 "2012-08-22T22:54:54Z")

</div>

You can change the mouse wheel settings within your OS, but that will affect other programs (like a browser). If you like, I can move this over to the feature request section, and perhaps it can be implemented by:

- allowing the user to choose how many pixels to move per wheel “notch”, or
- move x number of pixels per “line”, which is the OS mouse wheel setting of how many lines to move per notch

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [August 22, 2012, 10:58pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/3 "2012-08-22T22:58:56Z")

</div>

how about a setting that can be changed with code so I can figure out the window height and adjust the setting for each window for the amount of lines/pixels per notch?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 22, 2012, 11:03pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/4 "2012-08-22T23:03:52Z")

</div>

Try [JScrollBar#setUnitIncrement(int)](http://docs.oracle.com/javase/6/docs/api/javax/swing/JScrollBar.html#setUnitIncrement(int))

You can get the JScrollBar from a JScrollPane using [JScrollPane#getVerticalScrollBar()](http://docs.oracle.com/javase/6/docs/api/javax/swing/JScrollPane.html#getVerticalScrollBar())

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [August 22, 2012, 11:25pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/5 "2012-08-22T23:25:54Z")

</div>

cool I just put this in the internalFrameOpened on my startup window and it seems to make the scroll wheel much better for all my windows.

```auto
#increases scroll bar speed	
from javax.swing import SwingUtilities
from javax.swing import JScrollPane

scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source)

scrollPane.getVerticalScrollBar().setUnitIncrement(10)
```

---

<div class="post-metadata">

**Author:** ![rmonfront](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@rmonfront](https://forum.inductiveautomation.com/u/rmonfront)\
**Post date:** [July 26, 2017, 8:55pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/6 "2017-07-26T20:55:32Z")

</div>

Hello,

I’m asking if we could do the same with the scroll bar from a Template Repeater component ?

It would be very useful, and it is working for me and window scroll bar.

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [July 27, 2017, 2:23pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/7 "2017-07-27T14:23:42Z")

</div>

Template Repeater

```auto
from javax.swing import SwingUtilities
from javax.swing import JScrollPane

scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Repeater').getComponents()[1].getComponents()[2])

scrollPane.getVerticalScrollBar().setUnitIncrement(30) #scroll amount for wheel and arrows
scrollPane.getVerticalScrollBar().setBlockIncrement(30) #scroll amount clicking on scrollbar itself

```

Template Canvas

```auto
from javax.swing import SwingUtilities
from javax.swing import JScrollPane

scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Canvas').getComponents()[2].getComponents()[0])

scrollPane.getVerticalScrollBar().setUnitIncrement(30) #scroll amount for wheel and arrows
scrollPane.getVerticalScrollBar().setBlockIncrement(30) #scroll amount clicking on scrollbar itself

```

---

<div class="post-metadata">

**Author:** ![rmonfront](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@rmonfront](https://forum.inductiveautomation.com/u/rmonfront)\
**Post date:** [July 28, 2017, 6:00pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/8 "2017-07-28T18:00:20Z")

</div>

Can you explain me this part:  
"  
event.source.parent.getComponent(‘Template Repeater’).getComponents()[1].getComponents()[2])  
"

Because i got this error:  
Traceback (most recent call last):

File “event:visionWindowOpened”, line 6, in

TypeError: getComponent(): 1st arg can’t be coerced to int

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 28, 2017, 6:30pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/9 "2017-07-28T18:30:27Z")

</div>

Did you copy the script directly?  
In Jae’s example, he’s using `component.getComponents()` (note the plural), while the error you copied has `getComponent()` singular.

---

<div class="post-metadata">

**Author:** ![rmonfront](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@rmonfront](https://forum.inductiveautomation.com/u/rmonfront)\
**Post date:** [July 28, 2017, 7:39pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/10 "2017-07-28T19:39:07Z")

</div>

> [@jpark](#):
>
> SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Repeater').getComponents()[1].getComponents()[2])

Yes, i copied directly from your example.

but still have this error:

Traceback (most recent call last):

File "event:visionWindowOpened", line 4, in

TypeError: getComponent(): 1st arg can't be coerced to int

Ignition v7.9.4-beta1 (b2017061413)  
Java: Oracle Corporation 1.8.0\_131

Executed script on window event: visionWindow.visionWindowOpened:

from javax.swing import SwingUtilities  
from javax.swing import JScrollPane

scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane,SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Repeater').getComponents()[1].getComponents()[2]))

scrollPane.getVerticalScrollBar().setUnitIncrement(30) #scroll amount for wheel and arrows  
scrollPane.getVerticalScrollBar().setBlockIncrement(30) #scroll amount clicking on scrollbar itself

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 28, 2017, 9:38pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/11 "2017-07-28T21:38:00Z")

</div>

Ah. You can’t run these on a visionWindowOpened as is; when they step out to ‘event.source.parent’ they’re going outside of the typical Ignition boundaries. I’m not sure this will still work directly, but try replacing the `scrollPane =` line with this:

`scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane,SwingUtilities.getAncestorOfClass(JScrollPane, event.source.rootContainer.getComponent('Template Repeater').getComponents()[1].getComponents()[2]))`

---

<div class="post-metadata">

**Author:** ![rmonfront](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@rmonfront](https://forum.inductiveautomation.com/u/rmonfront)\
**Post date:** [July 31, 2017, 12:02pm UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/12 "2017-07-31T12:02:55Z")

</div>

> [@jpark](#):
>
> scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Repeater').getComponents()[1].getComponents()[2])

I cannot use the new line of code of the scrollPane in the visionWindowOpened it seems to have no error but my scrollbar stay with the same speed.

I move the code inside the Template Repeater on propertyChange event and it is working great now.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 24, 2017, 3:31am UTC](https://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043/13 "2017-11-24T03:31:11Z")

</div>

Sorry to revive such an old post, and apologies for the potentially obvious question… (I’m very new to Java)

When using getComponents(), what’s the reason for using the getAncestorOfClass function?

I noticed that the object returned from:

```auto
scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Repeater').getComponents()[1].getComponents()[2])

```

is exactly the same as the object returned from simply:

```auto
scrollPane = event.source.parent.getComponent('Template Repeater').getComponents()[1]

```

If the whole process of getting the scroll pane object was dynamic, I would understand this, however both the indexes of the getComponents() collection are hardcoded, so I don’t understand why the getting of the JScrollPane object should be made dynamic?  
Is there any way do achieve the same thing but fully dynamically without hardcoding the indexes?

Thanks in advance!  
Nick
