简体   繁体   中英

How to set minimum size of scrollbar thumb slider on SWT ScrollBar?

Specifically on a Windows XP machine, The width of the SWT ScrollBar Slider becomes incredibly thin when the internal scroll composite is very large. Is there a way to set the minimum width of the thumb slider to like 10-15px so that it doesn't get that thin? My specific case with this is when using NatTables with large amounts of data.

Hi I don't think you can do that, because the Scrollbar it's drawn by the OS. I think you have two options here, if you really need this feature:

1) implement you custom Scrollbar.

2) try to use/modify an existing custom Scrollbar, for instance this one: http://www.codeaffine.com/2014/12/17/sacrilege-custom-swt-scrollbar/

The scrollbar in NatTable is managed by the ViewportLayer . It internally uses instances of ScrollBarScroller for this, which are wrappers around a ScrollBar . To support custom scrollbars like the one posted in the other answer, the ViewportLayer supports that you set a custom ScrollBarScroller . This is explained in one of my blog posts here: NatTable with custom scrollbars .

You could for example set a customized instance of ScrollBarScroller where you override #setThumb(int) and there you ensure that the value of the thumb never gets below a certain minimum. Not sure if that would have any side effects on scrolling. But it should be worth a try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM