Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Absolute URLs for image in CSS files using IntelliJ IDEA

twasylDec 7 2012 — edited Dec 7 2012
Hi everyone,

I'm facing a problem with absolute URLs for images in a CSS file using JavaFX 2.2.3. Given the following FXML:
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import java.net.*?>

<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:id="root">
    <stylesheets>
        <URL value="@/com/twasyl/testerfx/resources/style/TesterFX.css" />
    </stylesheets>

    <children>
        <Button prefHeight="128" prefWidth="128">
            <styleClass>
                <String fx:value="testButton" />
            </styleClass>
        </Button>
    </children>
</AnchorPane>
And the given CSS file:
.testButton {
    -fx-background-image: url('/com/twasyl/testerfx/resources/images/globe.png');
    -fx-background-repeat: no-repeat;
}
The display is absolutely correct using NetBeans 7.2.1 but in IntelliJ 12 the image is not displayed. But if in my CSS file I use relative URL like this:
.testButton {
    -fx-background-image: url('../images/globe.png');
    -fx-background-repeat: no-repeat;
}
it's working in both NetBeans and IntelliJ. I've also tried to the URL locator by adding a @ at the beginning of the URL, without success. So I was wondering if it's more an IDE issue, or JavaFX one. Have anyone encounter this problem?

Thank you.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 4 2013
Added on Dec 7 2012
2 comments
1,517 views