这是该计划的快照: link
在这个场景中,我无法单击GridPane中的文本字段,复选框和按钮,但我可以使用TAB按钮遍历它们。另一个有趣的事实是,当我按下TAB时,按顺序排列:name-surname-email-confirm email-password-details-confirm password-selectcity-phone
我无法理解为什么我无法点击以及为什么订单不正常。注意:我可以单击其他文本,例如主页(它不在网格窗格中)
注意:由于我没有像setMouseTransparent(true)这样的语句,我的问题并没有归结为problem。另外,我问为什么TAB没有正确。
这是这个场景的控制者:
public class SignUpController
{
@FXML
private TextField nameField;
@FXML
private TextField surnameField;
@FXML
private TextField emailField;
@FXML
private TextField confirmEmailField;
@FXML
private TextField phoneField;
@FXML
private PasswordField passwordField;
@FXML
private PasswordField confirmPasswordField;
@FXML
private TextArea detailsField;
@FXML
private CheckBox signUpCheckBox;
@FXML
private Text warningMessage;
@FXML
private ComboBox cityList;
DatabaseConnector dc1 = new DatabaseConnector();
/**
* Events when sign up button is clicked
*/
public void cityListClicked()
{
cityList = new ComboBox();
cityList.getItems().addAll("Emre", "yeter ulan");
}
public void signUpClicked()
{
if(emailField.getText().equals(confirmEmailField.getText()))
{
if(passwordField.getText().equals(confirmPasswordField.getText()))
{
signUpCheckBox.setIndeterminate(false);
if(signUpCheckBox.isPressed())
{
dc1.addUser(new User(nameField.getText(), surnameField.getText(), passwordField.getText(), emailField.getText(), detailsField.getText(), Integer.parseInt(phoneField.getText()), new ArrayList<RealEstate>(), new ArrayList<>()));
warningMessage.setText("Signup successful");
}
else
warningMessage.setText("You have to accept to continue");
}
else
warningMessage.setText("Passwords don't match");
}
else
warningMessage.setText("Emails don't match");
}
}
和FXML文件:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.SignUpController">
<children>
<VBox layoutX="86.0" layoutY="93.0" spacing="10.0" AnchorPane.bottomAnchor="60.0" AnchorPane.leftAnchor="30.0" AnchorPane.rightAnchor="30.0" AnchorPane.topAnchor="60.0">
<children>
<GridPane prefHeight="341.0" prefWidth="740.0">
<columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" maxWidth="284.0" minWidth="10.0" prefWidth="132.0" />
<ColumnConstraints fillWidth="false" hgrow="SOMETIMES" maxWidth="608.0" minWidth="10.0" prefWidth="608.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="80.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Name" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Surname" GridPane.rowIndex="1" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Email" GridPane.rowIndex="2" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Confirm Email" GridPane.rowIndex="3" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Password" GridPane.rowIndex="4" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Confirm Password" GridPane.rowIndex="5" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="City" GridPane.rowIndex="6" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Phone" GridPane.rowIndex="7" />
<TextField fx:id="nameField" GridPane.columnIndex="1">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="surnameField" layoutX="110.0" layoutY="13.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="emailField" layoutX="110.0" layoutY="43.0" GridPane.columnIndex="1" GridPane.rowIndex="2">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="confirmEmailField" layoutX="110.0" layoutY="73.0" mouseTransparent="true" GridPane.columnIndex="1" GridPane.rowIndex="3">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</TextField>
<PasswordField fx:id="passwordField" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</PasswordField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Details" GridPane.rowIndex="8" />
<TextArea fx:id="detailsField" prefHeight="80.0" prefWidth="354.0" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="8">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</TextArea>
<TextField fx:id="phoneField" layoutX="110.0" layoutY="133.0" GridPane.columnIndex="1" GridPane.rowIndex="7">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</TextField>
<PasswordField fx:id="confirmPasswordField" GridPane.columnIndex="1" GridPane.rowIndex="5">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</PasswordField>
<ComboBox fx:id="cityList" onAction="#cityListClicked" onContextMenuRequested="#cityListClicked" prefWidth="150.0" promptText="Select City" GridPane.columnIndex="1" GridPane.rowIndex="6">
<opaqueInsets>
<Insets />
</opaqueInsets>
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</ComboBox>
</children>
</GridPane>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Sign up">
<font>
<Font size="29.0" />
</font>
<VBox.margin>
<Insets left="100.0" />
</VBox.margin>
</Text>
<CheckBox fx:id="signUpCheckBox" mnemonicParsing="false" text="By signing up, I accept the Real Estate Wizard's Terms of Service and Privacy Policy">
<font>
<Font size="15.0" />
</font>
<VBox.margin>
<Insets left="50.0" />
</VBox.margin>
</CheckBox>
<Button mnemonicParsing="false" onAction="#signUpClicked" text="Sign Up">
<font>
<Font size="15.0" />
</font>
<VBox.margin>
<Insets left="50.0" />
</VBox.margin>
</Button>
<Text fx:id="warningMessage" fill="#e11616" strokeType="OUTSIDE" strokeWidth="0.0">
<VBox.margin>
<Insets left="50.0" />
</VBox.margin>
</Text>
</children>
</VBox>
<fx:include source="Template.fxml" />
</children>
</AnchorPane>