I have created a scene on scene builder using TabPane but when I run I have this error:
gen 20, 2024 9:02:31 PM com.sun.javafx.application.PlatformImpl startup
AVVERTENZA: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @46f15f7f'
gen 20, 2024 9:02:32 PM javafx.fxml.FXMLLoader$ValueElement processValue
AVVERTENZA: Loading FXML document with JavaFX API of version 19 by JavaFX runtime of version 18.0.2
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:901)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassCastException: class javafx.scene.control.TabPane cannot be cast to class javafx.scene.layout.BorderPane (javafx.scene.control.TabPane and javafx.scene.layout.BorderPane are in unnamed module of loader 'app')
at it.polito.s284166.Tesi.EntryPoint.start(EntryPoint.java:19)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
... 1 more
this is the film fxml of scene builder:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<TabPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="540.0" prefWidth="768.0" tabClosingPolicy="UNAVAILABLE" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="it.polito.s284166.Tesi.FXMLController">
<tabs>
<Tab text="Ricerca">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" style="-fx-background-color: lightyellow;">
<children>
<ImageView fitHeight="513.0" fitWidth="768.0" opacity="0.56" pickOnBounds="true">
<image>
<Image url="@../../../../../sfondo-di-impronta-di-tracce-di-pneumatici-gialli/SL-092920-35860-24.jpg" />
</image>
</ImageView>
<TextField fx:id="txtKilometer" layoutX="413.0" layoutY="22.0" prefHeight="26.0" prefWidth="254.0" promptText="Inserisci un valore numerico" style="-fx-border-color: black;" />
<Label alignment="CENTER" layoutX="34.0" layoutY="22.0" prefHeight="0.0" prefWidth="178.0" style="-fx-background-color: white; -fx-border-color: black;" text="Max Chilometri">
<font>
<Font size="16.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="34.0" layoutY="115.0" prefHeight="0.0" prefWidth="178.0" style="-fx-background-color: white; -fx-border-color: black;" text="Tipo di carburante">
<font>
<Font size="16.0" />
</font>
</Label>
<ComboBox fx:id="cmbColor" layoutX="413.0" layoutY="159.0" prefHeight="26.0" prefWidth="254.0" style="-fx-background-color: white; -fx-border-color: Black;" />
<RadioButton layoutX="413.0" layoutY="210.0" mnemonicParsing="false" text="Prima Mano">
<toggleGroup>
<ToggleGroup fx:id="owner" />
</toggleGroup></RadioButton>
<RadioButton layoutX="566.0" layoutY="210.0" mnemonicParsing="false" text="Seconda mano" toggleGroup="$owner" />
<Label alignment="CENTER" layoutX="34.0" layoutY="68.0" prefHeight="0.0" prefWidth="178.0" style="-fx-background-color: white; -fx-border-color: black;" text="Prezzo Massimo">
<font>
<Font size="16.0" />
</font>
</Label>
<TextField fx:id="txtPrice" layoutX="413.0" layoutY="68.0" prefHeight="26.0" prefWidth="254.0" promptText="Inserisci un valore numerico" style="-fx-border-color: black;" />
<ComboBox fx:id="cmbFuel" layoutX="413.0" layoutY="115.0" prefHeight="26.0" prefWidth="254.0" style="-fx-background-color: white; -fx-border-color: Black;" />
<Label alignment="CENTER" layoutX="34.0" layoutY="159.0" prefHeight="0.0" prefWidth="178.0" style="-fx-background-color: white; -fx-border-color: black;" text="Colore">
<font>
<Font size="16.0" />
</font>
</Label>
<Button fx:id="btnCreaGrafo" layoutX="34.0" layoutY="244.0" mnemonicParsing="false" onAction="#doCreaGrafo" prefHeight="26.0" prefWidth="694.0" style="-fx-background-color: white; -fx-border-color: black;" text="Cerca veicolo" />
<TableView fx:id="table" layoutX="34.0" layoutY="286.0" prefHeight="200.0" prefWidth="697.0">
<columns>
<TableColumn fx:id="ID" prefWidth="48.000030517578125" text="ID" />
<TableColumn fx:id="Make" prefWidth="72.80001831054688" text="Marca" />
<TableColumn fx:id="Model" prefWidth="172.00006103515625" text="Modello" />
<TableColumn fx:id="engine" prefWidth="70.4000244140625" text="Cavalli" />
<TableColumn fx:id="year" prefWidth="75.0" text="Anno" />
<TableColumn fx:id="kilometer" prefWidth="135.99993896484375" text="Chilometri" />
<TableColumn fx:id="price" prefWidth="119.199951171875" text="Prezzo" />
</columns>
</TableView>
</children></AnchorPane>
</content>
</Tab>
<Tab text="Ricerca Avanzata">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<ImageView fitHeight="514.0" fitWidth="768.0" opacity="0.56" pickOnBounds="true">
<image>
<Image url="@../../../../../sfondo-di-impronta-di-tracce-di-pneumatici-gialli/SL-092920-35860-24.jpg" />
</image>
</ImageView>
<ComboBox fx:id="cmbAuto1" layoutX="403.0" layoutY="32.0" prefHeight="27.0" prefWidth="326.0" style="-fx-background-color: white; -fx-border-color: Black;" />
<Label alignment="CENTER" layoutX="44.0" layoutY="32.0" prefHeight="27.0" prefWidth="304.0" style="-fx-background-color: white; -fx-border-color: black;" text="Seleziona auto">
<font>
<Font size="16.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="44.0" layoutY="74.0" prefHeight="27.0" prefWidth="304.0" style="-fx-background-color: white; -fx-border-color: black;" text="Inserisci budget">
<font>
<Font size="16.0" />
</font>
</Label>
<TextField fx:id="txtBudget1" layoutX="403.0" layoutY="74.0" prefHeight="26.0" prefWidth="327.0" promptText="Inserisci un valore numerico" style="-fx-border-color: black;" />
<Button fx:id="btnRicorsione1" layoutX="37.0" layoutY="127.0" mnemonicParsing="false" onAction="#doRicorsione" prefHeight="26.0" prefWidth="694.0" style="-fx-background-color: white; -fx-border-color: black;" text="Trova combinazione migliore">
<font>
<Font size="16.0" />
</font>
</Button>
<TextArea fx:id="txtResult1" layoutX="37.0" layoutY="191.0" prefHeight="200.0" prefWidth="700.0" style="-fx-background-color: white; -fx-border-color: black;" />
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
</TabPane>
this is the FXMLController class:
package it.polito.s284166.Tesi;
import it.polito.s284166.Tesi.model.*;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TabPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
public class FXMLController {
private Model model;
@FXML
private TabPane mainPane;
@FXML
private ResourceBundle resources;
@FXML
private URL location;
@FXML
private TableColumn<?, ?> ID;
@FXML
private TableColumn<?, ?> Make;
@FXML
private TableColumn<?, ?> Model;
@FXML
private Button btnCreaGrafo;
@FXML
private Button btnRicorsione1;
@FXML
private ComboBox<?> cmbAuto1;
@FXML
private ComboBox<?> cmbColor;
@FXML
private ComboBox<?> cmbFuel;
@FXML
private TableColumn<?, ?> engine;
@FXML
private TableColumn<?, ?> kilometer;
@FXML
private ToggleGroup owner;
@FXML
private TableColumn<?, ?> price;
@FXML
private TableView<?> table;
@FXML
private TextField txtBudget1;
@FXML
private TextField txtKilometer;
@FXML
private TextField txtPrice;
@FXML
private TextArea txtResult1;
@FXML
private TableColumn<?, ?> year;
@FXML
void doCreaGrafo(ActionEvent event) {
}
@FXML
void doRicorsione(ActionEvent event) {
}
@FXML
void initialize() {
assert ID != null : "fx:id=\"ID\" was not injected: check your FXML file 'Scene.fxml'.";
assert Make != null : "fx:id=\"Make\" was not injected: check your FXML file 'Scene.fxml'.";
assert Model != null : "fx:id=\"Model\" was not injected: check your FXML file 'Scene.fxml'.";
assert btnCreaGrafo != null : "fx:id=\"btnCreaGrafo\" was not injected: check your FXML file 'Scene.fxml'.";
assert btnRicorsione1 != null : "fx:id=\"btnRicorsione1\" was not injected: check your FXML file 'Scene.fxml'.";
assert cmbAuto1 != null : "fx:id=\"cmbAuto1\" was not injected: check your FXML file 'Scene.fxml'.";
assert cmbColor != null : "fx:id=\"cmbColor\" was not injected: check your FXML file 'Scene.fxml'.";
assert cmbFuel != null : "fx:id=\"cmbFuel\" was not injected: check your FXML file 'Scene.fxml'.";
assert engine != null : "fx:id=\"engine\" was not injected: check your FXML file 'Scene.fxml'.";
assert kilometer != null : "fx:id=\"kilometer\" was not injected: check your FXML file 'Scene.fxml'.";
assert owner != null : "fx:id=\"owner\" was not injected: check your FXML file 'Scene.fxml'.";
assert price != null : "fx:id=\"price\" was not injected: check your FXML file 'Scene.fxml'.";
assert table != null : "fx:id=\"table\" was not injected: check your FXML file 'Scene.fxml'.";
assert txtBudget1 != null : "fx:id=\"txtBudget1\" was not injected: check your FXML file 'Scene.fxml'.";
assert txtKilometer != null : "fx:id=\"txtKilometer\" was not injected: check your FXML file 'Scene.fxml'.";
assert txtPrice != null : "fx:id=\"txtPrice\" was not injected: check your FXML file 'Scene.fxml'.";
assert txtResult1 != null : "fx:id=\"txtResult1\" was not injected: check your FXML file 'Scene.fxml'.";
assert year != null : "fx:id=\"year\" was not injected: check your FXML file 'Scene.fxml'.";
}
public void setModel(Model model) {
this.model = model;
}
}
this is the entryPoint class:
package it.polito.s284166.Tesi;
import javafx.application.Application;
import static javafx.application.Application.launch;
import it.polito.s284166.Tesi.model.Model;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class EntryPoint extends Application {
@Override
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/Scene.fxml"));
BorderPane root = loader.load();
FXMLController controller = loader.getController();
Model model = new Model();
controller.setModel(model);
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("/styles/Styles.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
and this is the main class:
package it.polito.tdp.imdb;
public class Main {
public static void main(String[] args) {
EntryPoint.main(args);
}
}
I have created the scene of scene builder, I have copied and pasted the skeleton of the view on fxml controller class, I have runned the main class and appear that error, I have checked scene.fxml file but I don't find the BorderPane tag suggested from error message and I have not used that in fxml controller class too. Can you help to find the problem with this project?