레스토랑에서 예약 관리에 대한 프로그램을 만들려고하고 있지만 지금까지 해결할 수 없었던 내구성이 있습니다. 이러한 코드 조각에서버튼 클릭시 FXML - 텍스트 필드가 오른쪽으로 이동
봐 :
Customer.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10" prefWidth="300" prefHeight="300">
<padding>
<Insets top="25" right="25" bottom="10" left="25"/>
</padding>
<Label GridPane.rowIndex="0" GridPane.columnIndex="0" text="Name"/>
<Label GridPane.rowIndex="1" GridPane.columnIndex="0" text="ID"/>
<Label GridPane.rowIndex="2" GridPane.columnIndex="0" text="Phone Number"/>
<Label GridPane.rowIndex="3" GridPane.columnIndex="0" text="Bringing..."/>
<TextField GridPane.rowIndex="0" GridPane.columnIndex="1" fx:id="name"/>
<TextField GridPane.rowIndex="1" GridPane.columnIndex="1" fx:id="id"/>
<TextField GridPane.rowIndex="2" GridPane.columnIndex="1" fx:id="phonenumber"/>
<TextField GridPane.rowIndex="3" GridPane.columnIndex="1" fx:id="bringing"/>
<Button GridPane.rowIndex="4" GridPane.columnIndex="0" text="Assign Table" fx:id="notedetails"/>
<HBox GridPane.rowIndex="4" GridPane.columnIndex="1" alignment="BASELINE_RIGHT">
<Button text="Back" fx:id="back"/>
</HBox>
<Text GridPane.rowIndex="5" GridPane.columnIndex="0" fx:id="noted"/>
</GridPane>
@FXMLController(value = "/fxml/customer.fxml", title = "Customer Details")
public class CustomerController {
@FXML
private TextField name;
@FXML
private TextField id;
@FXML
private TextField phonenumber;
@FXML
private TextField bringing;
@FXML
@ActionTrigger("notedetails")
private Button notedetails;
@FXML
@BackAction
private Button back;
@FXML
private Text noted;
@Inject
private Restaurant restaurant;
@ActionMethod("notedetails")
public void notedetails() {
noted.setText("Your details have been noted!");
String customerName = name.getText();
String customerID = id.getText();
String customerPhoneNumber = phonenumber.getText();
int customerBringing = Integer.parseInt(bringing.getText());
Customer customer = new Customer(customerName, customerID, customerPhoneNumber, customerBringing);
restaurant.addCustomer(customer);
}
}
내가 메인 클래스를 실행 CustomerController.java, 나는 갔다 고객 창을 열고 세부 정보를 입력 한 후 텍스트 필드가 오른쪽으로 이동했습니다. 코드를 확인하고 다시 확인하기 위해 선생님에게 문제에 대해 이야기했지만 코드에 문제가 있는지 찾을 수 없었습니다.
나는이 문제에 대해 다른 사람이 묻지 않아서 놀랐다. 그래서 내가 한 일이 될 수도있다. 내 코드에서 뭔가를 놓친 경우 도움을 요청하거나 문제를 해결할 방법을 찾으십시오.
그래도 작동하지 않습니다. 라벨이나 텍스트 필드에 대해 이야기하고 있습니까? –
나는 텍스트 필드에 대해 이야기하고있다. 나는 'BACK'버튼에 정렬을 지정하면 텍스트 필드에도 정렬을 지정해야한다고 생각합니다. – sudhir