@Gfd

Ошибка локализации JavaFX?

Начал создавать приложение на javafx и столкнулся с ошибкой. Нигде не могу найти, как она решается

Вот класс Main:
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);
    }
}


Вот файл fxml:

<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>

Ошибка:
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

Ошибка появляется лишь при добавлении label текст ключа из файла property.
text="%key_MainMenu_Title"
Название ключа я написал правильно. Прошу помогите, кто знает
  • Вопрос задан
  • 1843 просмотра
Решения вопроса 1
Пригласить эксперта
Ответы на вопрос 1
@Gfd Автор вопроса
Я всё понял, добавил инициализацию в контроллере и всё заработало)
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
Bell Integrator Хабаровск
До 400 000 ₽
Bell Integrator Ижевск
До 400 000 ₽
Bell Integrator Ульяновск
До 400 000 ₽
07 мая 2024, в 23:46
3000 руб./за проект
07 мая 2024, в 23:32
1200 руб./в час
07 мая 2024, в 23:27
1000 руб./за проект