I'm writing a JavaFX library containing a custom control. I've create a custom Skin for this control where I layout a TextField and a Button. When the button gets clicked a Popup windows should be opened.
The trouble I'm having is that the Popup is transparent. How can I make it opaque? I tried to configure the background in the CSS but without success.
The relevant code is inside the Skin implemenation of this custom control. The CSS is referenced by the getUserAgentStylesheet() method of the custom control. The custom control has the styleClass "custom-control".
Basically the Skin says:
- render the cutom control as a TextField and a Button
- if this button (part of the Skin) gets pressed: pop up a window with another custom control (which has it own Skin etc.)
Here is the relevant code:
public class SomeControlSkin implements Skin<SomeControl> {
private SomeControl control;
private OtherControl otherControl = new OtherControl();
private Popup popup = new Popup();
public SomeControlSkin(SomeControl someControl){
this.someControl = someControl;
otherControl.fooProperty().bind(someControl.fooProperty());
...
popupControl.getContent().add(otherControl);
...
}
...
}
and
.some-control {
-fx-skin: "somePackage.SomeControlSkin";
}
.some-control .popup{
-fx-background-color: yellow;
}
.some-control .other-control{
-fx-background-color: yellow;
}
I also tried with PopupControl but it didn't work either.
Note: This is a cross-post:
https://forums.oracle.com/forums/thread.jspa?messageID=10819020
Edit:
I managed to get a small step further. The following will fill the Popup:
popupControl.getScene().setFill(Color.YELLOW);
But how can I do this with CSS?
I even tried:
.some-control {
-fx-skin: "somePackage.SomeControlSkin";
-fx-background-color: black;
-fx-background-insets: 0;
-fx-fill: black;
}
.other-control {
-fx-skin: "somePackage.OtherControlSkin";
-fx-background-color: black;
-fx-background-insets: 0;
-fx-fill: black;
}
But it didn't change the background no matter if I added the control to a Popup or to the main scene!? (I'm not sure if fill or background should do the trick and I'm not sure if I have to set the insets and to what value, though).
I also tried to add a styleClass:
popupControl.getContent().add(otherControl);
otherControl.getStyleClass().add("other-control-popup");
and
.other-control-popup {
-fx-background-color: black;
-fx-background-insets: 0;
-fx-fill: black;
}
But this didn't work either.