I created a Maven JavaFX project using the archetype that I found here: https://github.com/openjfx/javafx-maven-archetypes
Everything runs smoothly, I can run a project with some labels, a text box and some buttons without issues. However, when I try adding in a WebView element (although recognized by the Scene Builder in IntelliJ) I cannot get the imports to work.
My pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>untitled3</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-web -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>16</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>org.dianavrabie.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
My main fxml document to describe the view:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<VBox alignment="TOP_CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.dianavrabie.PrimaryController">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
<children>
<AnchorPane prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="14.0" text="POLYNOMIAL CALCULATOR" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="System Bold" size="36.0" />
</font></Label>
<Label layoutY="53.0" text="Polynomial 1" AnchorPane.leftAnchor="0.0">
<font>
<Font size="18.0" />
</font>
</Label>
<Label layoutY="90.0" text="Polynomial 2" AnchorPane.leftAnchor="0.0">
<font>
<Font size="18.0" />
</font>
</Label>
<TextField layoutX="124.0" layoutY="54.0" prefHeight="25.0" prefWidth="359.0" AnchorPane.leftAnchor="117.0" AnchorPane.rightAnchor="0.0" />
<TextField layoutX="117.0" layoutY="91.0" prefHeight="25.0" prefWidth="359.0" AnchorPane.leftAnchor="117.0" AnchorPane.rightAnchor="0.0" />
<Button layoutY="136.0" mnemonicParsing="false" text="ADD" AnchorPane.leftAnchor="0.0">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Button>
<Button layoutX="57.0" layoutY="136.0" mnemonicParsing="false" text="SUBTRACT" AnchorPane.leftAnchor="57.0">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Button>
<Button layoutX="156.0" layoutY="136.0" mnemonicParsing="false" text="MULTIPLY">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Button>
<Button layoutX="251.0" layoutY="137.0" mnemonicParsing="false" text="DIVIDE">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Button>
<Button layoutX="324.0" layoutY="137.0" mnemonicParsing="false" text="DERIVATIVE">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Button>
<Button layoutX="432.0" layoutY="137.0" mnemonicParsing="false" text="INTEGRATE">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Button>
<Button layoutX="538.0" layoutY="137.0" mnemonicParsing="false" text="CLEAR" textFill="#fc5400">
<font>
<Font size="14.0" />
</font>
</Button>
</children>
</AnchorPane>
</children>
</VBox>
And the main app class
package org.dianavrabie;
import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
/**
* JavaFX App
*/
public class App extends Application {
private static Scene scene;
@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("primary"), 640, 480);
stage.setScene(scene);
stage.show();
}
static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}
public static void main(String[] args) {
launch(args);
}
}
What do I need to do to get the WebView to work? I'm really new at this and I can't seem to find a solution.