Задать вопрос

Ошибка при построении FXML на Java, как это исправить?

есть программа formfx, которая должна открывать formParta.fxml
formParta:
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>


<VBox alignment="TOP_CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <TextField id="login" alignment="CENTER" promptText="Логин">
         <VBox.margin>
            <Insets top="60.0" />
         </VBox.margin>
      </TextField>
      <PasswordField id="password" alignment="CENTER" promptText="Пароль">
         <VBox.margin>
            <Insets top="10.0" />
         </VBox.margin>
      </PasswordField>
      <TextField id="userid" alignment="CENTER" prefHeight="0.0" prefWidth="503.0" promptText="user id">
         <VBox.margin>
            <Insets top="40.0" />
         </VBox.margin>
      </TextField>
      <ChoiceBox id="message" prefHeight="25.0" prefWidth="339.0">
         <VBox.margin>
            <Insets top="10.0" />
         </VBox.margin>
      </ChoiceBox>
      <Button id="sendbutton" mnemonicParsing="false" prefHeight="25.0" prefWidth="85.0" text="Отправить">
         <VBox.margin>
            <Insets top="10.0" />
         </VBox.margin>
      </Button>
   </children>
</VBox>

formfx:
package deleveryClub;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;



public class formfx extends Application{
    public static void main(String[] args){
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        Group group = new Group();
        Parent content = FXMLLoader.load(getClass().getResource("formParta.fxml"));
        BorderPane root = new BorderPane();
        root.setCenter(content);
        group.getChildren().add(root);

        //primaryStage.setTitle("Parta");
        primaryStage.setScene(new Scene(group, 400, 400));
        primaryStage.show();
    }
}


выдает ошибку:
"C:\Program Files\Java\jdk-11.0.2\bin\java.exe" --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.5\lib\idea_rt.jar=5378:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.5\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\blurryface\IdeaProjects\first_project\target\classes;C:\Users\blurryface\.m2\repository\org\openjfx\javafx-fxml\12\javafx-fxml-12.jar;C:\Users\blurryface\.m2\repository\org\openjfx\javafx-fxml\12\javafx-fxml-12-win.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-java\3.141.59\selenium-java-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-api\3.141.59\selenium-api-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\3.141.59\selenium-chrome-driver-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\3.141.59\selenium-edge-driver-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\3.141.59\selenium-opera-driver-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\openjfx\javafx-graphics\11\javafx-graphics-11.jar;
Exception in Application start method
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x32224179) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x32224179
javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
	... 1 more
Exception running application deleveryClub.formfx

Process finished with exit code 1
  • Вопрос задан
  • 478 просмотров
Подписаться 1 Средний Комментировать
Пригласить эксперта
Ответы на вопрос 1
zolt85
@zolt85
Программист
Stacktrace иногда полезно читать.

Добавьте в параметры запуска приложения строку
--add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED
Ответ написан
Ваш ответ на вопрос

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

Похожие вопросы