Style a Popup in a Skin

Florian Brunner fbrunnerlist at gmx.ch
Fri Sep 8 19:24:02 UTC 2017


Hi,

Sorry to bother this list with this question, but I didn' receive any answer on Stackoverflow and I'm not sure if or how this is supported at all:
https://stackoverflow.com/questions/45467626/custom-skin-style-popup
https://stackoverflow.com/questions/14610639/custom-control-opaque-popup

In a Skin implementation of a custom control I want to style a Popup.

I guess I have to use the PopupControl[1], not Popup[2]. 
PopupControl popup = new PopupControl();
popup.getScene().setRoot(popupContentPane);
popup.setAutoHide(true);
popup.setAnchorLocation(PopupWindow.AnchorLocation.WINDOW_BOTTOM_LEFT);
popup.setStyle("-fx-background-color: red;");
popup.getStyleClass().add("my-popup");
popup.show(getSkinnable(), screenLocation.getX(), screenLocation.getY()); 
The skinnable overrides the userAgentStylesheet: 
@Override
public String getUserAgentStylesheet() {
    return Stylesheets.getDefaultStylesheet();
} 
But neither the style, nor the styleClass nor any styleClass applied to any child node of popupContentPane has some effect. 
If I understand the documentation[3] correctly the popup should use the stylesheet of the ownerNode (here the skinnable). 
How can I style a popup in a skin? 
Or should I file an enhancement request?

Kind regards,Florian

--------
[1] http://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/PopupControl.html
[2] http://docs.oracle.com/javase/8/javafx/api/javafx/stage/Popup.html
[3] http://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/PopupControl.html#getStyleableParent--


More information about the openjfx-dev mailing list