package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
Parent root =FXMLLoader.load(getClass().getResource("Welcome.fxml"));
Scene scene = new Scene(root,600,400);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
package application;
import java.io.IOException;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class Controller {
@FXML
Button buttonyes,buttonno;
private Stage stage;
private Scene scene;
private Parent root;
public void yes(ActionEvent event) throws IOException {
root = FXMLLoader.load(getClass().getResource("Order.fxml"));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public void no(ActionEvent event) {
System.exit(0);
}
}
package application;
import java.io.IOException;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class OrderController {
@FXML
private Stage stage;
private Scene scene;
private Parent root;
Button buttonorder;
Button buttonclear;
Button buttonback;
public void back(ActionEvent event) throws IOException {
root = FXMLLoader.load(getClass().getResource("Welcome.fxml"));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller">
<children>
<ImageView fitHeight="281.0" fitWidth="267.0" layoutX="14.0" layoutY="60.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/menu.png" />
</image>
</ImageView>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#e88c38" height="400.0" layoutX="295.0" stroke="TRANSPARENT" strokeType="INSIDE" width="305.0" />
<Text fill="#e2e2e2" layoutX="323.0" layoutY="154.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Herzlich Willkommen!">
<font>
<Font name="Arial Black" size="21.0" />
</font>
</Text>
<Text fill="#e2e2e2" layoutX="338.0" layoutY="180.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Möchten Sie bestellen?">
<font>
<Font name="Arial" size="21.0" />
</font>
</Text>
<Button fx:id="buttonyes" layoutX="381.0" layoutY="214.0" mnemonicParsing="false" onAction="#yes" style="-fx-background-color: #e2e2e2;" text="Ja">
<font>
<Font name="Arial Black" size="15.0" />
</font>
</Button>
<Button fx:id="buttonno" layoutX="456.0" layoutY="214.0" mnemonicParsing="false" onAction="#no" style="-fx-background-color: #e2e2e2;" text="Nein">
<font>
<Font name="Arial Black" size="15.0" />
</font>
</Button>
</children>
</AnchorPane>
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="781.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller">
<children>
<Pane layoutX="181.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="118.0" fitWidth="118.0" layoutX="41.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/pig.png" />
</image>
</ImageView>
<Pane layoutX="-3.0" layoutY="112.0" prefHeight="42.0" prefWidth="207.0">
<children>
<Label layoutX="14.0" layoutY="3.0" text="Hamburger">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="20.0" text="3€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="137.0" layoutY="8.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="181.0" layoutY="150.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="110.0" fitWidth="111.0" layoutX="45.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/hen.png" />
</image>
</ImageView>
<Pane layoutX="-3.0" layoutY="108.0" prefHeight="42.0" prefWidth="207.0">
<children>
<Label layoutX="14.0" layoutY="3.0" text="Chickenburger ">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="20.0" text="3€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="137.0" layoutY="8.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="181.0" layoutY="300.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="110.0" fitWidth="111.0" layoutX="45.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/nuggets.png" />
</image>
</ImageView>
<Pane layoutX="-3.0" layoutY="108.0" prefHeight="42.0" prefWidth="207.0">
<children>
<Label layoutX="14.0" layoutY="3.0" text="Nuggets">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="20.0" text="2€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="137.0" layoutY="9.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="181.0" layoutY="450.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="139.0" fitWidth="139.0" layoutX="-17.0" layoutY="6.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/soft-drink.png" />
</image>
</ImageView>
<Pane layoutX="95.0" layoutY="-4.0" prefHeight="159.0" prefWidth="111.0">
<children>
<Label layoutX="33.0" layoutY="30.0" text="Sprite">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="47.0" layoutY="52.0" text="1€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="28.0" layoutY="88.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="381.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="118.0" fitWidth="118.0" layoutX="47.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/cheese.png" />
</image>
</ImageView>
<Pane layoutX="-3.0" layoutY="108.0" prefHeight="42.0" prefWidth="207.0">
<children>
<Label layoutX="14.0" layoutY="3.0" text="Cheeseburger ">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="20.0" text="2,50€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="137.0" layoutY="9.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="381.0" layoutY="150.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="102.0" fitWidth="102.0" layoutX="49.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/pommes-frittes.png" />
</image>
</ImageView>
<Pane layoutX="-3.0" layoutY="108.0" prefHeight="42.0" prefWidth="207.0">
<children>
<Label layoutX="14.0" layoutY="3.0" text="Pommes ">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="20.0" text="1,50€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="137.0" layoutY="9.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="381.0" layoutY="300.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="110.0" fitWidth="111.0" layoutX="45.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/ice-cream.png" />
</image>
</ImageView>
<Pane layoutX="-3.0" layoutY="110.0" prefHeight="42.0" prefWidth="207.0">
<children>
<Label layoutX="14.0" layoutY="3.0" text="Eis">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="20.0" text="1€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="137.0" layoutY="8.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="381.0" layoutY="450.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="128.0" fitWidth="128.0" layoutX="-17.0" layoutY="11.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/soda.png" />
</image>
</ImageView>
<Pane layoutX="89.0" prefHeight="159.0" prefWidth="111.0">
<children>
<Label layoutX="33.0" layoutY="30.0" text="Fanta">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="47.0" layoutY="52.0" text="1€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="28.0" layoutY="88.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="581.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="102.0" fitWidth="102.0" layoutX="49.0" layoutY="9.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/ginkgo.png" />
</image>
</ImageView>
<Pane layoutY="108.0" prefHeight="42.0" prefWidth="207.0">
<children>
<Label layoutX="14.0" layoutY="3.0" text="Veggieburger">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="20.0" text="2€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="137.0" layoutY="9.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="581.0" layoutY="150.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="110.0" fitWidth="111.0" layoutX="45.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/salad.png" />
</image>
</ImageView>
<Pane layoutX="-3.0" layoutY="110.0" prefHeight="42.0" prefWidth="207.0">
<children>
<Label layoutX="14.0" layoutY="3.0" text="Salat">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="20.0" text="2€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="137.0" layoutY="8.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="581.0" layoutY="300.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="139.0" fitWidth="139.0" layoutX="-15.0" layoutY="6.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/cola.png" />
</image>
</ImageView>
<Pane layoutX="89.0" layoutY="-4.0" prefHeight="159.0" prefWidth="111.0">
<children>
<Label layoutX="39.0" layoutY="30.0" text="Cola">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="47.0" layoutY="52.0" text="1€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="28.0" layoutY="88.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane layoutX="581.0" layoutY="450.0" prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: lightgrey;">
<children>
<ImageView fitHeight="139.0" fitWidth="139.0" layoutX="-16.0" layoutY="6.0">
<image>
<Image url="@../../../../../OneDrive/Documents/Schule/lockdown%202/info/projektarbeit/pepsi.png" />
</image>
</ImageView>
<Pane layoutX="89.0" layoutY="-4.0" prefHeight="159.0" prefWidth="111.0">
<children>
<Label layoutX="33.0" layoutY="30.0" text="Pepsi">
<font>
<Font name="Arial Black" size="14.0" />
</font>
</Label>
<Label layoutX="47.0" layoutY="52.0" text="1€">
<font>
<Font name="Arial" size="15.0" />
</font>
</Label>
<ChoiceBox layoutX="28.0" layoutY="88.0" prefHeight="22.0" prefWidth="56.0" />
</children>
</Pane>
</children>
</Pane>
<Pane prefHeight="600.0" prefWidth="182.0" style="-fx-background-color: lightgrey;">
<children>
<Button fx:id="buttonorder" layoutX="41.0" layoutY="214.0" mnemonicParsing="false" onAction="#order" prefHeight="50.0" prefWidth="100.0" style="-fx-background-color: WHITE;" text="BESTELLEN">
<font>
<Font name="Arial Black" size="11.0" />
</font>
</Button>
<Button fx:id="buttonclear" layoutX="41.0" layoutY="275.0" mnemonicParsing="false" onAction="#clear" prefHeight="50.0" prefWidth="100.0" style="-fx-background-color: WHITE;" text="LÖSCHEN">
<font>
<Font name="Arial Black" size="11.0" />
</font>
</Button>
<Button fx:id="buttonback" layoutX="41.0" layoutY="336.0" mnemonicParsing="false" onAction="#back" prefHeight="50.0" prefWidth="100.0" style="-fx-background-color: WHITE;" text="ZURÜCK">
<font>
<Font name="Arial Black" size="11.0" />
</font>
</Button>
</children>
</Pane>
</children>
</AnchorPane>
错误
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1862)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1729)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8889)
at javafx.controls/javafx.scene.control.Button.fire(Button.java:203)
at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3856)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1851)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2584)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:409)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:299)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:447)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:446)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:76)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:273)
at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:83)
at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1857)
... 46 more
Caused by: javafx.fxml.LoadException: Error resolving onAction='#order', either the event handler is not in the Namespace or there is an error in the script.
/C:/Users/daydr/eclipse-workspace/Projektarbeit-Bestellen/Bestellservice/bin/application/Order.fxml:308
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2703)
at javafx.fxml/javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:620)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:780)
at javafx.fxml/javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2924)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2639)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3323)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3280)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3249)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3222)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3199)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3192)
at application.Controller.yes(Controller.java:23)
... 57 more
我将非常感谢你能给我的任何帮助,因为这真的很令人沮丧,请记住,我只是学到这一点:
以下两行出现在您的问题中的堆栈跟踪中。
Caused by: javafx.fxml.LoadException: Error resolving onAction='#order', either the event handler is not in the Namespace or there is an error in the script.
/C:/Users/daydr/eclipse-workspace/Projektarbeit-Bestellen/Bestellservice/bin/application/Order.fxml:308
所以问题出在文件order.fxml
上。问题与该文件中的字符串onaction='#order'
有关。
从您在问题中发布的文件的内容中,我看到了以下一行:
<Button fx:id="buttonorder" layoutX="41.0" layoutY="214.0" mnemonicParsing="false" onAction="#order" prefHeight="50.0" prefWidth="100.0" style="-fx-background-color: WHITE;" text="BESTELLEN">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="781.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller">
@FXML
private void order(ActionEvent event)
我在第一个场景上有一个简单的按钮,应该会导致第二个场景。当我点击按钮时,它改变场景,但只显示一个空白屏幕。如果我关闭原始舞台,然后显示一个包含新场景的新舞台,它会正常工作,但我不想打开一个新窗口。 这是我的控制器类: 主类:
所以我有一个画布,它不会被破坏,因为它保持和滑块显示进度条。它还有一个按钮,当加载进度为0.9时,它是可交互的。我遇到的问题是当我单击按钮时(请参阅active ateNewScene())。基本上,当我单击按钮时,我加载了我的场景并禁用了我的画布。但问题是,在我禁用画布后,旧场景仍然显示大约0.5秒,并且比加载新场景时。我想要的是,在画布被禁用后,新场景应该会出现。而不会在短时间内看到旧场景。
为什么会引发主线程上的网络异常?its在异步任务上 } 编辑: 完整代码: logcat:
我创建了一个游戏,我想给它添加一个开始屏幕,我使用FXML添加了它,还添加了两个按钮(开始和退出)。 按下开始按钮后,我希望游戏加载场景并切换到游戏开始。我对如何做有一个粗略的想法,但我有点挣扎,因为我的SampleController类不知道如何启动游戏等,因为所有代码(以及加载初始开始菜单的代码)都在我的主类中,所以我尝试了这样的事情: 我尝试使用一个函数来切换场景,但它不起作用,也试图使用获
我看了很多页,试图找出如何切换场景,但都没有成功。 我有一个计算器,我的目标是选择一个菜单选项来更改计算器(即:基础和科学)。现在我只是在测试,所以这里是我到目前为止与这个问题相关的代码(我使用的是场景生成器): 编辑我已经尝试了很多东西。不管怎样,我总是得到这个NullPointerException。我有一种感觉,这可能与在场景生成器中设置某些内容有关,但我就是找不到答案 工作代码: 我使用下
我想在2个不同的场景之间切换: 问题是当我从场景2切换到场景1时,场景1中加载的所有图像都不在那里(这很明显,因为我正在创建一个新场景,而不是“加载”场景1。 当我从场景2切换到场景1时,有什么方法可以保留已经加载的图像吗? 场景1