Cześć wszystkim,
od jakiegoś czasu staram się nauczyć Javy...
Ostatnio natrafiłem na problem z kompilacją:
BazaOPP.java
package bazaopp;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class BazaOPP extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
FXMLDocumentController.java
package bazaopp;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class FXMLDocumentController implements Initializable {
@FXML
private Label label;
@FXML
private AnchorPane root;
@FXML
private TextField text_Device;
@FXML
private TextField text_Serial;
@FXML
private TextField text_Owner;
@FXML
private TextField text_Location;
@FXML
private TextField text_Info;
@FXML
private TextField text_Other;
@Override
public void initialize(URL location, ResourceBundle resources) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
FXMLDocument.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane id="AnchorPane" fx:id="root" prefHeight="680.0" prefWidth="1402.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.141" fx:controller="bazaopp.FXMLDocumentController">
<children>
<Label fx:id="label" layoutX="503.0" layoutY="14.0" minHeight="16" minWidth="69" prefHeight="68.0" prefWidth="494.0" text="Baza Danych Łączność">
<font>
<Font name="System Bold" size="44.0" />
</font></Label>
<TableView layoutX="183.0" layoutY="105.0" prefHeight="455.0" prefWidth="1205.0">
<columns>
<TableColumn prefWidth="224.0" text="Device" />
<TableColumn prefWidth="134.0" text="Serial number" />
<TableColumn prefWidth="153.0" text="Owner" />
<TableColumn prefWidth="200.0" text="Location" />
<TableColumn prefWidth="264.0" text="Information" />
<TableColumn prefWidth="229.0" text="Other" />
</columns>
</TableView>
<Button layoutX="1062.0" layoutY="629.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="157.0" text="ADD" />
<Button layoutX="1231.0" layoutY="629.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="157.0" text="DELETE" />
<TextField fx:id="text_Device" alignment="TOP_CENTER" layoutX="183.0" layoutY="583.0" prefHeight="25.0" prefWidth="256.0" promptText="Device" />
<TextField fx:id="text_Serial" alignment="TOP_CENTER" layoutX="452.0" layoutY="583.0" prefHeight="25.0" prefWidth="256.0" promptText="Serial number" />
<TextField fx:id="text_Owner" alignment="TOP_CENTER" layoutX="725.0" layoutY="583.0" prefHeight="25.0" prefWidth="256.0" promptText="Owner" />
<TextField fx:id="text_Location" alignment="TOP_CENTER" layoutX="997.0" layoutY="583.0" prefHeight="25.0" prefWidth="256.0" promptText="Location" />
<TextField fx:id="text_Info" alignment="TOP_CENTER" layoutX="183.0" layoutY="617.0" prefHeight="25.0" prefWidth="256.0" promptText="Information" />
<Button layoutX="1296.0" layoutY="583.0" mnemonicParsing="false" text="Button" />
<TextField fx:id="text_Other" alignment="TOP_CENTER" layoutX="452.0" layoutY="617.0" prefHeight="25.0" prefWidth="256.0" promptText="Other" />
<ImageView fitHeight="175.0" fitWidth="269.0" layoutY="7.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@img/LOGOOPP3.png" />
</image>
</ImageView>
</children>
</AnchorPane>
Treść błędu:
jfx-project-run:
Executing C:\Users\kamil\OneDrive\Dokumenty\NetBeansProjects\BazaOPP\dist\run482229473\BazaOPP.jar using platform C:\Java\jdk1.8.0_172\jre/bin/java
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/kamil/OneDrive/Dokumenty/NetBeansProjects/BazaOPP/dist/run482229473/BazaOPP.jar!/bazaopp/FXMLDocument.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at bazaopp.BazaOPP.start(BazaOPP.java:23)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Caused by: java.lang.UnsupportedOperationException: FXMLDocument.fxml
at bazaopp.FXMLDocumentController.initialize(FXMLDocumentController.java:68)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 17 more
Exception running application bazaopp.BazaOPP
Java Result: 1
Deleting directory C:\Users\kamil\OneDrive\Dokumenty\NetBeansProjects\BazaOPP\dist\run482229473
jfxsa-run:
BUILD SUCCESSFUL (total time: 4 seconds)
Po próbie kompilacji nie otwiera się pragram z SceneBuildera. Proszę o pomoc bardziej doświadczonych kolegów. :)