Java FX não carrega imagens

2 respostas Resolvido
java
N


Aqui mostra o comparativo entre o arquivo FXML quando aberto no scenebuilder e quando compilo!

todas as imagens não carregam(BG, icones e a logo!)

Eu achei um tópico falando que é um bug do JDK mas não encontrei uma solução. Meu inglês também não ajuda muito!

FXML

<Button fx:id="menuItem02" alignment="CENTER_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="230.0" mnemonicParsing="false" onAction="#showSubmenu" styleClass="menu-bt" text="Editor">
                                <graphic>
                                    <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true" styleClass="menu-icon">
                                        <image>
                                            <Image url="@../../assets/editor.png" />
                                        </image>
                                    </ImageView>
                                </graphic>
                            </Button>

                            <Button fx:id="menuItem03" alignment="CENTER_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="230.0" mnemonicParsing="false" onAction="#showSubmenu" styleClass="menu-bt" text="Mods &#10;(Alpha)" textAlignment="RIGHT">
                                <graphic>
                                    <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true" styleClass="menu-icon">
                                        <image>
                                            <Image url="@../../assets/mods.png" />
                                        </image>
                                    </ImageView>
                                </graphic>
                            </Button>

                            <Button fx:id="menuItem04" alignment="CENTER_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="230.0" mnemonicParsing="false" onAction="#showSubmenu" styleClass="menu-bt" text="Settings">
                                <graphic>
                                    <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true" styleClass="menu-icon">
                                        <image>
                                            <Image url="@../../assets/settings.png" />
                                        </image>
                                    </ImageView>
                                </graphic>
                            </Button>

                            <Button fx:id="menuItem05" alignment="CENTER_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="230.0" mnemonicParsing="false" onAction="#showSubmenu" styleClass="menu-bt" text="About">
                                <graphic>
                                    <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true" styleClass="menu-icon">
                                        <image>
                                            <Image url="@../../assets/info.png" />
                                        </image>
                                    </ImageView>
                                </graphic>
                            </Button>

                            <Button fx:id="menuItem06" alignment="CENTER_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="230.0" mnemonicParsing="false" onAction="#showSubmenu" styleClass="menu-bt" text="Quit">
                                <graphic>
                                    <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true" styleClass="menu-icon">
                                        <image>
                                            <Image url="@../../assets/quit.png" />
                                        </image>
                                    </ImageView>
                                </graphic>
                            </Button>
                        </children>
                        <padding>
                            <Insets top="100.0" />
                        </padding>
                    </VBox>
                    <!-- end.MENU -->

                    <VBox fx:id="submenu" prefHeight="200.0" prefWidth="30.0" styleClass="submenu-container">
                    </VBox>
                    <!-- end.SUBMENU -->
                </children>
            </HBox>
            <!-- end.SIDEBAR -->
        </left>
     <center>
        <VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER" styleClass="start-screen ">
           <children>
              <ImageView fitHeight="150.0" fitWidth="500.0" pickOnBounds="true" preserveRatio="true">
                 <image>
                    <Image url="@../../assets-raw/logo.png" />
                 </image>
              </ImageView>
           </children>
        </VBox>
     </center>

    </BorderPane>

    <!-- LIGHT EFFECT -->
    <Rectangle arcHeight="5.0" arcWidth="5.0" blendMode="OVERLAY" focusTraversable="true" height="900.0" mouseTransparent="true" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="1440.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
        <fill>
            <RadialGradient centerX="0.5168067226890757" centerY="0.5" radius="0.5">
                <stops>
                    <Stop color="TRANSPARENT" />
                    <Stop color="TRANSPARENT" offset="0.2569832402234637" />
                    <Stop color="#00000061" offset="1.0" />
                </stops>
            </RadialGradient>
        </fill>
        <cursor>
            <Cursor fx:constant="DEFAULT" />
        </cursor>
    </Rectangle>

</children>

2 Respostas

J

Somente poderei dar uma olhada no seu codigo no final da proxima semana, se até lá não tiver conseguido resolver dá um toke.
[]'s

N
Solucao aceita

Resolvido. Eu mexi na estrutura do projeto, e não tinha reconfigurado a saída… foi só ir em Projects Resources e configurar! Ele não havia feito o refactor corretamente!

Criado 31 de dezembro de 2019
Ultima resposta 2 de jan. de 2020
Respostas 2
Participantes 2