Diamond
Diamond

Reputation: 7483

Scrollbars recently appeared

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).

Upvotes: 3

Views: 168

Answers (2)

Diamond
Diamond

Reputation: 7483

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).

Upvotes: 7

SolStack
SolStack

Reputation: 404

In Codename one scrollbar coming back Shai indicates that the preferred method for removing scrollbars is to define the theme constant scrollVisibleBool=false.

The Theme editor would not let me add this constant to the theme as it was not in the drop-down selector. In order to add it I had to do the following:

  1. Put the theme editor in XML Team Mode, save the theme, close the editor.
  2. Add the following line to the theme.xml file <val key="@tabPlacementInt" value="0" />
  3. Then open the theme editor and save it again.

After this, the scrollbars are no longer visible.

Upvotes: 0

Related Questions