Change ScrollBar Width through scripting

Here is an example of how to change the scrollbar width through scripting.

This example uses the javax.swing and java.awt to access the prefferedsize() property of the scrollbar. From what I gather, accessing the .width property for the JScrollBar directy is undesirable as it would bypass the LayoutManager inside Java (also, I couldn’t get it to work - says .width is not a valid property). So instead I set the preferredsize() property. This allows the layout manager to change the width property and appropriately handle resizing.

from javax.swing import JScrollBar
from java.awt import Dimension

D=Dimension(50,20)

event.source.parent.getComponent("Table").getVerticalScrollBar().setPreferredSize(D)
3 Likes

Thanks for posting that example.

Thanks. Useful code for touch screen implementations.