Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-fx-background-image using Javafx CSS -> Inline Style is not working! #677

Open
ctoabidmaqbool1 opened this issue Feb 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ctoabidmaqbool1
Copy link

I have tried using both single and double quotation marks and both are not working using Javafx CSS -> Style:

-fx-background-image: url('image.jpg'); or -fx-background-image: url("image.jpg"); not working!

While using external Stylesheet e.g. Style.css, it's working fine:

image

FXML.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>

<VBox alignment="TOP_CENTER" prefHeight="600.0" prefWidth="335.0" stylesheets="@Style.css" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <ImageView fitHeight="170.0" fitWidth="426.0" preserveRatio="true">
         <image>
            <Image url="@image.jpg" />
         </image>
      </ImageView>
      <AnchorPane prefHeight="200.0" prefWidth="200.0" style="-fx-background-image: url('image.jpg');" />
      <Pane prefHeight="200.0" prefWidth="200.0" />
   </children>
</VBox>

Style.css

Pane {
	-fx-background-image: url('image.jpg');
}

Why it's not working using only Scene Builder (internal css style) e.g. without external CSS?

Also tried in latest Scene Builder available yet e.g .21 and Windows 10 OS.

@ctoabidmaqbool1 ctoabidmaqbool1 added the bug Something isn't working label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant