G
G
Gfd2016-01-23 18:32:16
Java
Gfd, 2016-01-23 18:32:16

JavaFX localization error?

I started to create an application on javafx and ran into an error. I can't find anywhere how it is solved
. Here is the Main class:

public class Main extends Application {
    /*  Start program!!!  */

    FXMLLoader fXMLLoader_MainMenu;

    @Override
    public void start(Stage stageMainMenu) throws Exception {
        StorageVariables storageVariables=new StorageVariables();

        fXMLLoader_MainMenu=new FXMLLoader();
        fXMLLoader_MainMenu.setLocation(getClass().getResource("MainMenu.fxml"));
        fXMLLoader_MainMenu.setResources(ResourceBundle.getBundle("sample.Properties.MainMenu", new Locale("ru")));

        Parent panel = FXMLLoader.load(getClass().getResource("MainMenu.fxml"));
        Scene scene=new Scene(panel,700,500);
        stageMainMenu.setScene(scene);
        stageMainMenu.setTitle(fXMLLoader_MainMenu.getResources().getString("key_MainMenu_Title")); //titleMainMenu
        stageMainMenu.show();

        System.out.println("   Program start!");
    }

    public static void main(String[] args) throws Exception{
        launch(args);
    }
}

Here is the fxml file:
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.ControllerProgramGuide">
   <children>
      <ImageView fitHeight="500.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true">
         <image>
            <Image url="@res/ФонГлавногоОкна.png" />
         </image>
      </ImageView>
      <ImageView fitHeight="45.0" fitWidth="29.0" layoutX="647.0" layoutY="18.0" preserveRatio="true">
         <image>
            <Image url="@res/ЗнакВопроса.png" />
         </image>
      </ImageView>
      <ImageView fx:id="imgBtnQuestion" blendMode="HARD_LIGHT" fitHeight="50.0" fitWidth="50.0" layoutX="635.0" layoutY="16.0" opacity="0.0" pickOnBounds="true" preserveRatio="true">
         <image>
            <Image url="@res/ДляКнопки5050.png" />
         </image>
      </ImageView>
      <Button fx:id="btnQuestion" focusTraversable="false" layoutX="635.0" layoutY="15.0" mnemonicParsing="false" onMouseEntered="#mouseEnteredBtnQUESTION" onMouseExited="#mouseExitedBtnQUESTION" onMousePressed="#inquiryQuestionBtnQUESTION" opacity="0.0" prefHeight="50.0" prefWidth="50.0" />
      <Label layoutX="215.0" layoutY="65.0" prefHeight="35.0" prefWidth="275.0" text="%key_MainMenu_Title" textFill="#070606" >
         <font>
            <Font size="25.0" />
         </font>
      </Label>
   </children>
</Pane>

Mistake:
No resources specified.
/D:/workspace/Assist/out/production/Assist/sample/MainMenu.fxml:29
  at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:308)
  at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:200)
  at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:591)
  at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2472)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2177)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2069)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2830)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2809)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2795)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2782)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2771)
  at sample.Main.start(Main.java:24)
  at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
  at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
  at java.lang.Thread.run(Thread.java:745)

Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
  at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
  at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
  at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
  at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException: No resources specified.
  at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:308)
  at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:200)
  at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:591)
  at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2472)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2177)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2069)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2830)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2809)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2795)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2782)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2771)
  at sample.Main.start(Main.java:24)
  at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
  at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
  ... 1 more

The error appears only when adding the label text of the key from the property file.
text="%key_MainMenu_Title"
I wrote the name of the key correctly. Please help, who knows

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Victor Alenkov, 2016-01-23
@Gfd

stackoverflow.com/questions/10143392/javafx-2-and-...

G
Gfd, 2016-01-23
@Gfd

I understood everything, added initialization in the controller and it all worked)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question