-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8u11
-
Windows8.1
I am building a Custom Control in JavaFX8 and I want to separate style from code as much as possible. In my control, I am using a Button but am applying the shape to the button in the CSS file via -fx-shape: <my SVG path description>. Everything is working fine, except when the window first opens. My shape has been applied to the button, but layoutChildren() does not get called after the application of the CSS rules. Applying the rules has changed the size of the button, but my control has not been given the opportunity to layout its children appropriately. If I manually re-size the window, layoutChildren() is called and everything works fine from then on.
I'm hesitant to set any preferred width or height settings in my code - I haven't had to so far, just a minimum width - because they may not be correct based on what shape a graphical designer might want to apply to that button in the future.
I should draw particular attention to the fact that my stylesheet is being applied by overriding getUserAgentStylesheet() in my control class - not by providing a stylesheet to the Scene.
It is very possible I'm doing something wrong, or not doing something I should. I am not overriding any of the calculateMin/Pref/Max methods - I was hoping that setting the min size in CSS would work.
Another interesting problem here is that the control behaves as expected (scaling horizontally) until I move the thumb on the slider. Then, many times, the min width of the whole control seems to change. I can solve this by setting a minWidth on my control, but this also breaks my intent of allowing a graphic editor to change the button settings only and have things work. Its an interesting effect however and may point to my problem. I'm never setting a prefWidth/prefHeight - may be my issue. Again, if I set a minWidth on my control (in CSS) that allows enough space for the buttons, it works fine - but IMHO, that violates the paradigm that would allow a designer to simply change the CSS on the button, and nothing else, and have the control work properly.
Sample code attached in comments.
Thanks!
I'm hesitant to set any preferred width or height settings in my code - I haven't had to so far, just a minimum width - because they may not be correct based on what shape a graphical designer might want to apply to that button in the future.
I should draw particular attention to the fact that my stylesheet is being applied by overriding getUserAgentStylesheet() in my control class - not by providing a stylesheet to the Scene.
It is very possible I'm doing something wrong, or not doing something I should. I am not overriding any of the calculateMin/Pref/Max methods - I was hoping that setting the min size in CSS would work.
Another interesting problem here is that the control behaves as expected (scaling horizontally) until I move the thumb on the slider. Then, many times, the min width of the whole control seems to change. I can solve this by setting a minWidth on my control, but this also breaks my intent of allowing a graphic editor to change the button settings only and have things work. Its an interesting effect however and may point to my problem. I'm never setting a prefWidth/prefHeight - may be my issue. Again, if I set a minWidth on my control (in CSS) that allows enough space for the buttons, it works fine - but IMHO, that violates the paradigm that would allow a designer to simply change the CSS on the button, and nothing else, and have the control work properly.
Sample code attached in comments.
Thanks!