Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8314683

TextArea: scroll bar size and content padding

XMLWordPrintable

      When changing TextArea font (to a very large or a very small size), the scroll bars and content padding unexpectedly change (see the screenshot).

      The scroll bars' thumb and track width should not change, and they in theory should be the same as with other components.

      The content padding, on the other hand, might track the font size, except it does not always. To reproduce, use the MonkeyTester
      https://github.com/andy-goryachev-oracle/MonkeyTest

      - select TextArea page
      - make sure the text = Long, font size = 12, wrap text is off
      - observe minimal content padding and a reasonable scrollbar size
      - change the font to 72
      - observe no change in the content padding, and the scroll bar is prevented by JDK-8307117
      - click on the text
      - observe the padding has increased and scroll bar size is now way too large
      - select Text page, then TextArea page again (this will re-create TextArea Page using the large font)
      - change font size to 12
      - observe scroll bar and content padding remain large.

      There seems to be some interplay due to missing update (to be fixed by JDK-8307117), but in general, the scroll bar size should not, in my opinion, track the font size of a single component. It might track some global UI element size, but FX does not seem to have one and instead depends on "em" in the stylesheet:

      modena.css:
      ```
      .text-area .content {
          /*the is 1px less top and bottom than TextInput because of scrollpane border */
          -fx-padding: 0.25em 0.583em 0.25em 0.583em; /* 3 7 3 7 */
          -fx-cursor: text;
          -fx-background-color:
              linear-gradient(from 0px 0px to 0px 4px, derive(-fx-control-inner-background, -8%), -fx-control-inner-background);
          -fx-background-radius: 2;
      }



      .scroll-pane > .scroll-bar:horizontal > .increment-button,
      .scroll-pane > .scroll-bar:horizontal > .decrement-button {
          -fx-padding: 0.166667em 0.25em 0.25em 0.25em; /* 2 3 3 3 */
      }
      .scroll-pane > .scroll-bar:vertical > .increment-button,
      .scroll-pane > .scroll-bar:vertical > .decrement-button {
          -fx-padding: 0.25em 0.25em 0.25em 0.166667em; /* 3 3 3 2 */
      }
      ```
       
      edit: this might be considered as an RFE, but I think it's a bug.
      edit2: another possible failure mode is that setting caret via mouse click ends up with caret which is incorrectly positioned and has a wrong size

            angorya Andy Goryachev
            angorya Andy Goryachev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: