Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollbars recently appeared

Tags:

codenameone

I'm revisiting some older projects and a new build with the latest library has added an ugly scroll bar to my scrolling containers and lists.

I put in theme entries for 'Scroll' and "ScrollThumb" with transparency 0 and border empty. It removed some but not all, ticking or unticking scroll visible in the Designer doesn't seem to have much effect.

This happened sometime in the last few weeks. I can't find a pattern of what's causing it. (I think it may be new in v3.5).

like image 708
Diamond Avatar asked Jun 04 '26 20:06

Diamond


1 Answers

Here is my trick for removing scrollbar everywhere:

UIManager.getInstance().setLookAndFeel(new DefaultLookAndFeel(UIManager.getInstance()) {
    @Override
    public void bind(Component cmp) {
        if (cmp instanceof Container) {
            cmp.setScrollVisible(false);
        }
    }
});

I placed that piece of code in the init method of my main class.

Edit (May 09 2019):

You may experience some weird UI behavior using the code above. My experience so far is RadioButton and Checkbox components not rendering properly when I change their images with the code below:

((DefaultLookAndFeel) UIManager.getInstance().getLookAndFeel()).setCheckBoxImages(checkedImage, unCheckedImage);
((DefaultLookAndFeel) UIManager.getInstance().getLookAndFeel()).setCheckBoxFocusImages(checkedImage, unCheckedImage, checkedImage, unCheckedImage);

Solution (May 09 2019):

Add the following to the init method of your main class:

UIManager.getInstance().getLookAndFeel().setFocusScrolling(false);
UIManager.getInstance().getLookAndFeel().setFadeScrollBar(false);

...and set a theme constant scrollVisibleBool to false. (I think CN1 defaults this to false but I still set it anyway).

like image 80
Diamond Avatar answered Jun 08 '26 01:06

Diamond