2

I'm using javafx to build a sort of todo list program and using CSS to style it. I have an issue that I'm trying to resolve where when I reach the end of my textarea to the point where it starts to scroll and the scrollbar appears, the background from the CSS file I applied to my text area disappears.

Currently this is the code for the CSS file that I have applied to the text area.

.text-area .scroll-pane:fitToWidth:fitToHeight .viewport .content {
-fx-background-color: 
        linear-gradient(
        from 0px 0px to 0px 10.5px,
        repeat,
        gainsboro,
        gainsboro 6.25%,
        cornsilk 6.25%,
        cornsilk
         );

}

The file gives the textarea a notebook-esque look and works perfectly. However as I mentioned, I can't figure out how to get it to repeat/not disappear as soon as the textarea begins to scroll.

Crossouts
  • 21
  • 2
  • this looks like you're specifying a scroll-pane inside a text-area, when your description and common sense would be the opposite, but perhaps I'm misunderstanding something. What happens if you change the order so that `.text-area` is last and not first? – MMAdams Nov 29 '17 at 21:22
  • Can you post the relevant Java and/or FXML that creates the text area? – James_D Nov 29 '17 at 21:32
  • @MMAdams I believe that textareas in java have a scrollpane encapsulated within them correct me if I'm wrong. I'm also using Scene Builder to build this program so I got that path from using the CSS Analyzer and it seems that using this path to .content was the only way to style the background for the text area with CSS. – Crossouts Nov 30 '17 at 05:47
  • please read http://stackoverflow.com/help/mcve and provide an example as described there – kleopatra Nov 30 '17 at 10:44
  • @ChrisElliott oh that makes sense then. I haven't used textareas much and assumed you had placed it in a scrollpane yourself. – MMAdams Nov 30 '17 at 15:02
  • @kleopatra is there something that is missing from my example that I should've added? I read that page before posting because I'm new to stackoverflow, but if I'm missing something that would help resolve this issue or that is standard protocol for this site please let me know. I felt that it was unnecessary to include any fxml because its just a standard addition of a textarea to a parent VBox within my program. The issue at hand for me is how to make a background repeat using CSS code because it seems to disappear whenever the textarea reaches the point at which it needs to scroll. – Crossouts Nov 30 '17 at 20:49
  • 1
    @MMAdams Thank you for your help I seem to have found the problem. The path that I got from CSS analyzer is scenebuilder seemed to be an inefficient path to styling the content pane of the textArea: ".text-area .scroll-pane:fitToWidth:fitToHeight .viewport .content". I simply changed it to "text-area .content" and then it seemed to work. The "scroll-pane:fitToWidth:fitToHeight" seemed to be the issue. – Crossouts Nov 30 '17 at 22:04
  • I'm glad you figured it out! You should write that as an answer and accept it, in case anyone else using scenebuilder runs into a similar problem, that way they know by looking at the question that a solution exists. – MMAdams Dec 01 '17 at 13:46

1 Answers1

0

I seem to have found the problem. The path that I got from CSS analyzer is scenebuilder seemed to be an inefficient path to styling the content pane of the textArea: ".text-area .scroll-pane:fitToWidth:fitToHeight .viewport .content". I simply changed it to "text-area .content" and then it seemed to work. The "scroll-pane:fitToWidth:fitToHeight" seemed to be the issue.

Crossouts
  • 21
  • 2