Ich habe aus verzweiflung ob ich etwas falsch mache das Beispiel von Orakel genommen und es in Netbeen angelegt. Mit "new FX Aplication" name: FXMLExample
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package fxmlexampel;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.fxml.FXMLLoader;
/**
*
* @author bo4
*/
public class FXMLExampel extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("fxml_example.fxml"));
Scene scene = new Scene(root, 300, 275);
stage.setTitle("FXML Welcome");
stage.setScene(scene);
stage.show();
}
}
--------------------------------------------
und dann FXML_ExampleController( anders als im Beispiel weil man )
package fxmlexampel;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
public class FXML_ExampleController{
@FXML private Text actiontarget;
@FXML private Text actiontarget1;
@FXML private TextField username11;
String username1a;
@FXML protected void handleTusername11(ActionEvent event){
username11.getText();
}
@FXML protected void handleSubmitButtonAction(ActionEvent event) {
actiontarget.setText("Sign in button pressed");
actiontarget1.setText(username1a);
}
}
-------------------------------
und dannn ein eues "fxml_exaple.fxml"
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.net.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane alignment="center" hgap="10" vgap="10" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="fxmlexample.FXMLExampleController">
<padding><Insets bottom="10" left="25" right="25" top="25" /></padding>
<children>
<Text text="Welcome" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="0" />
<Label text="User Name:" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<TextField fx:id="username11" onAction="#handleTusername11" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Password:" GridPane.columnIndex="0" GridPane.rowIndex="2" />
<PasswordField fx:id="passwordField" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<HBox alignment="bottom_right" spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="4">
<children>
<Button onAction="#handleSubmitButtonAction" text="Sign In" />
</children>
</HBox>
<Text fx:id="actiontarget" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<Text fx:id="actiontarget1" />
</children>
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
</rowConstraints>
</GridPane>
Ursprünglich ohne die actionstarget1
Das Ergebnis kein Fenster im gegensatz zum ersten Exampel. Das fxml fenster mit edit geöffnet sagt kann kein fx:controller="fxmlexample.FXMLExampleController">vorhanden.
Die Umbenennung ohne Unterstrich brachte kein Ergebnis. Dann hat Netbeen die Variable
---------------------------------------------
@FXML protected void handleSubmitButtonAction(ActionEvent event) {
actiontarget.setText("Sign in button pressed");
moniert "nicht vorhanden"
nach dem Einfügen
@FXML protected void handleTusername11(ActionEvent event){
username11.getText();
hat er alles erkannt. Keine weitere Fehlermeldung. Gestartet:
ant -f "C:\\Documents and Settings\\bo4\\My Documents\\NetBeansProjects\\FXMLExampel" jfxsa-run
init:
Deleting: C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\build\built-jar.properties
deps-jar:
Updating property file: C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\build\built-jar.properties
Compiling 2 source files to C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\build\classes
Copying 1 file to C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\build\classes
compile:
Created dir: C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\dist
Detected JavaFX Ant API version 1.3
Launching <fx:jar> task from C:\Program Files\Java\jdk1.8.0_131\jre\..\lib\ant-javafx.jar
Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.
Please set manifest.custom.codebase property to override the current default non-secure value '*'.
Launching <fx:deploy> task from C:\Program Files\Java\jdk1.8.0_131\jre\..\lib\ant-javafx.jar
No base JDK. Package will use system JRE.
No base JDK. Package will use system JRE.
jfx-deployment-script:
jfx-deployment:
jar:
Copying 12 files to C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\dist\run158209931
jfx-project-run:
Executing C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\dist\run158209931\FXMLExampel.jar using platform C:\Program Files\Java\jdk1.8.0_131\jre/bin/java
Exception in Application start method
Exception in thread "main" 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 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$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException:
file:/C:/Documents%20and%20Settings/bo4/My%20Documents/NetBeansProjects/FXMLExampel/dist/run158209931/FXMLExampel.jar!/fxmlexampel/fxml_example.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
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 fxmlexampel.FXMLExampel.start(FXMLExampel.java:25)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.ClassNotFoundException: fxmlexample.FXMLExampleController
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)
... 22 more
Java Result: 1
Deleting directory C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\dist\run158209931
jfxsa-run:
BUILD SUCCESSFUL (total time: 8 seconds)
------------------------------------------
denke ich toll aber kein Fenster.
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package fxmlexampel;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.fxml.FXMLLoader;
/**
*
* @author bo4
*/
public class FXMLExampel extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("fxml_example.fxml"));
Scene scene = new Scene(root, 300, 275);
stage.setTitle("FXML Welcome");
stage.setScene(scene);
stage.show();
}
}
--------------------------------------------
und dann FXML_ExampleController( anders als im Beispiel weil man )
package fxmlexampel;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
public class FXML_ExampleController{
@FXML private Text actiontarget;
@FXML private Text actiontarget1;
@FXML private TextField username11;
String username1a;
@FXML protected void handleTusername11(ActionEvent event){
username11.getText();
}
@FXML protected void handleSubmitButtonAction(ActionEvent event) {
actiontarget.setText("Sign in button pressed");
actiontarget1.setText(username1a);
}
}
-------------------------------
und dannn ein eues "fxml_exaple.fxml"
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.net.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane alignment="center" hgap="10" vgap="10" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="fxmlexample.FXMLExampleController">
<padding><Insets bottom="10" left="25" right="25" top="25" /></padding>
<children>
<Text text="Welcome" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="0" />
<Label text="User Name:" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<TextField fx:id="username11" onAction="#handleTusername11" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Password:" GridPane.columnIndex="0" GridPane.rowIndex="2" />
<PasswordField fx:id="passwordField" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<HBox alignment="bottom_right" spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="4">
<children>
<Button onAction="#handleSubmitButtonAction" text="Sign In" />
</children>
</HBox>
<Text fx:id="actiontarget" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<Text fx:id="actiontarget1" />
</children>
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
</rowConstraints>
</GridPane>
Ursprünglich ohne die actionstarget1
Das Ergebnis kein Fenster im gegensatz zum ersten Exampel. Das fxml fenster mit edit geöffnet sagt kann kein fx:controller="fxmlexample.FXMLExampleController">vorhanden.
Die Umbenennung ohne Unterstrich brachte kein Ergebnis. Dann hat Netbeen die Variable
---------------------------------------------
@FXML protected void handleSubmitButtonAction(ActionEvent event) {
actiontarget.setText("Sign in button pressed");
moniert "nicht vorhanden"
nach dem Einfügen
@FXML protected void handleTusername11(ActionEvent event){
username11.getText();
hat er alles erkannt. Keine weitere Fehlermeldung. Gestartet:
ant -f "C:\\Documents and Settings\\bo4\\My Documents\\NetBeansProjects\\FXMLExampel" jfxsa-run
init:
Deleting: C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\build\built-jar.properties
deps-jar:
Updating property file: C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\build\built-jar.properties
Compiling 2 source files to C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\build\classes
Copying 1 file to C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\build\classes
compile:
Created dir: C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\dist
Detected JavaFX Ant API version 1.3
Launching <fx:jar> task from C:\Program Files\Java\jdk1.8.0_131\jre\..\lib\ant-javafx.jar
Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.
Please set manifest.custom.codebase property to override the current default non-secure value '*'.
Launching <fx:deploy> task from C:\Program Files\Java\jdk1.8.0_131\jre\..\lib\ant-javafx.jar
No base JDK. Package will use system JRE.
No base JDK. Package will use system JRE.
jfx-deployment-script:
jfx-deployment:
jar:
Copying 12 files to C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\dist\run158209931
jfx-project-run:
Executing C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\dist\run158209931\FXMLExampel.jar using platform C:\Program Files\Java\jdk1.8.0_131\jre/bin/java
Exception in Application start method
Exception in thread "main" 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 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$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException:
file:/C:/Documents%20and%20Settings/bo4/My%20Documents/NetBeansProjects/FXMLExampel/dist/run158209931/FXMLExampel.jar!/fxmlexampel/fxml_example.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
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 fxmlexampel.FXMLExampel.start(FXMLExampel.java:25)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.ClassNotFoundException: fxmlexample.FXMLExampleController
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)
... 22 more
Java Result: 1
Deleting directory C:\Documents and Settings\bo4\My Documents\NetBeansProjects\FXMLExampel\dist\run158209931
jfxsa-run:
BUILD SUCCESSFUL (total time: 8 seconds)
------------------------------------------
denke ich toll aber kein Fenster.