5

I tried many times to make the vertical Scroll Bar of Textrea to be always active instead of being visible only when focus on the Textarea but I couldn't do that ! ..

any help please

Jason4Ever
  • 1,439
  • 4
  • 23
  • 43

2 Answers2

2

I know that a lot of time has passed since this question was asked but I still want to give the answer for those who need it. To make the ScrollBar visible you just need to access to it from the TextArea class while passing through the Scrollpane :

.text-area > .scroll-pane{

-fx-vbar-policy:always; /* Control the vertical ScrollBar (always,needed,never) */
-fx-hbar-policy:always; /* Control the horizontal ScrollBar (always,needed,never) */

}

Good luck !

Roy Shmuli
  • 4,979
  • 1
  • 24
  • 38
Bo Halim
  • 1,716
  • 2
  • 17
  • 23
  • I did a thorough search, and I had as a conclusion that you can not control the `scroll-pane` of the `text-area` with the **java** code or even place the `text-area` in a new `scroll-pane` since it already has its own , the only solution was to use **css**. – Bo Halim Jul 17 '17 at 16:35
1

If you wand declare that within the code you can use lookup:

for (Node node : textArea.lookupAll(".scroll-pane"))
    {
        if (node instanceof ScrollPane)
        {
            ((ScrollPane) node).setVbarPolicy(ScrollBarPolicy.ALWAYS);
        }
    }
}
Roy Shmuli
  • 4,979
  • 1
  • 24
  • 38