add dialog
This commit is contained in:
76
src/main/java/lodge/AccountDialog.java
Normal file
76
src/main/java/lodge/AccountDialog.java
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package lodge;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
|
import javafx.scene.control.Dialog;
|
||||||
|
import javafx.util.Callback;
|
||||||
|
import lodge.datamodel.Account;
|
||||||
|
import lodge.datamodel.Address;
|
||||||
|
import lodge.datamodel.EmailAddress;
|
||||||
|
|
||||||
|
public class AccountDialog extends Dialog<Account> {
|
||||||
|
|
||||||
|
private Address mailingAddress;
|
||||||
|
private EmailAddress emailAddress;
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
|
public Address getMailingAddress() {
|
||||||
|
return mailingAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMailingAddress(Address mailingAddress) {
|
||||||
|
this.mailingAddress = mailingAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailAddress getEmailAddress() {
|
||||||
|
return emailAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmailAddress(EmailAddress emailAddress) {
|
||||||
|
this.emailAddress = emailAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhoneNumber() {
|
||||||
|
return phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhoneNumber(String phoneNumber) {
|
||||||
|
this.phoneNumber = phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountDialog() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("accountdialog.fxml"));
|
||||||
|
fxmlLoader.setController(this);
|
||||||
|
try {
|
||||||
|
fxmlLoader.load();
|
||||||
|
} catch (IOException exception) {
|
||||||
|
throw new RuntimeException(exception);
|
||||||
|
}
|
||||||
|
getDialogPane().setContent(fxmlLoader.getRoot());
|
||||||
|
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
|
||||||
|
setTitle("Account Dialog");
|
||||||
|
setHeaderText("Enter Account Details");
|
||||||
|
setPropertyBindings();
|
||||||
|
setResultConverter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPropertyBindings() {
|
||||||
|
System.out.println("setPropertyBindings called.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setResultConverter() {
|
||||||
|
System.out.println("setResultConverter called.");
|
||||||
|
Callback<ButtonType, Account> accountResultConverter = (buttonType) -> {
|
||||||
|
if (buttonType == ButtonType.OK) {
|
||||||
|
return new Account(phoneNumber, mailingAddress, emailAddress);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
setResultConverter(accountResultConverter);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
package lodge;
|
package lodge;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
import lodge.datamodel.Account;
|
||||||
|
|
||||||
public class TestMainFxCommandButtonEventController {
|
public class TestMainFxCommandButtonEventController {
|
||||||
|
|
||||||
@@ -13,7 +18,16 @@ public class TestMainFxCommandButtonEventController {
|
|||||||
private void initialize() {
|
private void initialize() {
|
||||||
|
|
||||||
btnAdd.setOnAction((ev) -> {
|
btnAdd.setOnAction((ev) -> {
|
||||||
Platform.exit();
|
|
||||||
|
AccountDialog accomodationDialog= new AccountDialog();
|
||||||
|
|
||||||
|
Optional result = accomodationDialog.showAndWait();
|
||||||
|
|
||||||
|
if( result.isPresent()){
|
||||||
|
// add to storage
|
||||||
|
// bind to model
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
59
src/resources/media/accountdialog.fxml
Normal file
59
src/resources/media/accountdialog.fxml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?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.TextField?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="361.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/24.0.1">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="294.0" minWidth="-Infinity" prefWidth="168.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="477.0" minWidth="10.0" prefWidth="432.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="128.0" minHeight="10.0" prefHeight="43.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="189.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="309.0" minHeight="10.0" prefHeight="309.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Label prefHeight="18.0" prefWidth="165.0" text="Email:" />
|
||||||
|
<TextField promptText="email address" GridPane.columnIndex="1" />
|
||||||
|
<Label prefHeight="18.0" prefWidth="165.0" text="Phone Number:" GridPane.rowIndex="1" />
|
||||||
|
<Label prefHeight="18.0" prefWidth="165.0" text="Mailing Address:" GridPane.rowIndex="2" />
|
||||||
|
<TextField promptText="phone number" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
|
<VBox prefHeight="262.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||||
|
<children>
|
||||||
|
<Label text="Street" />
|
||||||
|
<TextField />
|
||||||
|
<GridPane prefHeight="152.0" prefWidth="432.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="210.0" minWidth="10.0" prefWidth="151.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="123.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="159.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="24.0" minHeight="10.0" prefHeight="17.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Label text="State" GridPane.columnIndex="1" />
|
||||||
|
<Label text="City" />
|
||||||
|
<Label text="Zip" GridPane.columnIndex="2" />
|
||||||
|
<TextField prefHeight="33.0" prefWidth="150.0" GridPane.rowIndex="1" />
|
||||||
|
<TextField prefHeight="33.0" prefWidth="120.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
|
<TextField prefHeight="33.0" prefWidth="159.0" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
<ButtonBar prefHeight="38.0" prefWidth="429.0">
|
||||||
|
<buttons/>
|
||||||
|
</ButtonBar>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
Reference in New Issue
Block a user