就像本主题的对象一样,我试图保存来自textField和passwordField的值插入而没有成功:(
准确地说,我正在使用eclipse和ScaneBuilder
我已经创建了FXML文件(如下)
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="300.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/11.0.1" fx:controller="application.Login">
<children>
<PasswordField fx:id= "passwordInput" layoutX="232.0" layoutY="174.0" prefHeight="25.0" prefWidth="267.0" />
<TextField fx:id= "textInput" layoutX="232.0" layoutY="75.0" prefHeight="26.0" prefWidth="267.0" />
<ButtonBar layoutX="232.0" layoutY="246.0" prefHeight="40.0" prefWidth="267.0">
<buttons>
<Button mnemonicParsing="false" onaction="#resetPWD" text="Reset PWD" />
<Button mnemonicParsing="false" onaction="#exitLogin" text="Exit" />
<Button mnemonicParsing="false" onaction="#loginButton" text="Login" />
</buttons>
</ButtonBar>
<Label layoutX="57.0" layoutY="72.0" prefHeight="25.0" prefWidth="131.0" text="username:">
<font>
<Font size="24.0" />
</font>
</Label>
<Label layoutX="57.0" layoutY="174.0" prefHeight="25.0" prefWidth="131.0" text="Password:">
<font>
<Font size="24.0" />
</font>
</Label>
</children>
</AnchorPane>
并在login.java文件下方:
//prelevo la stringa inserita nel campo TextField
@FXML TextField passwordInput;
String passwordDigit = passwordInput.getText().toString();
@FXML TextField textInput;
String usernameDigit = textInput.getText().toString();
public void loginButton(actionEvent actionEvent) {
//if pwd and user are ok open a new scane and in same time close this one
System.out.println(passwordDigit);
System.out.println(usernameDigit);
}
public static void main(String[] args) {
launch(args);
}
有人可以帮助我解决我的问题吗?并且如果可以解释我为什么日食向我显示此错误消息 在此先感谢所有人
卢克