我是java的新手,所以我得请你帮忙:P.我正在创建非常简单的程序,但我坚持验证密码和登录textField.我想知道那段代码有什么问题,你能帮帮我吗?
调节器
package sample;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.PasswordField;
import java.awt.*;
public class Controller {
@FXML
public TextField login,password;
public void LoginButtonClicked(ActionEvent event)
{
if(login.getText().equals("yes")&&password.getText().equals("yes"))
{
System.out.print("Congratulations");
}
else
{
System.out.print("no");
}
}
}
Run Code Online (Sandbox Code Playgroud)
FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<top>
<VBox BorderPane.alignment="CENTER">
<children>
<MenuBar>
<menus>
<Menu mnemonicParsing="false" text="Profile">
<items>
<MenuItem …Run Code Online (Sandbox Code Playgroud)