updates
This commit is contained in:
@@ -15,6 +15,7 @@ public class TestMainFx extends Application {
|
||||
Scene scene = new Scene(root, 800, 600);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import lodge.datamodel.Account;
|
||||
import lodge.datamodel.Address;
|
||||
import lodge.datamodel.EmailAddress;
|
||||
|
||||
public class AccountDialog extends Dialog<Account> {
|
||||
public class TestMainFxAccountDialog extends Dialog<Account> {
|
||||
|
||||
private Address mailingAddress;
|
||||
private EmailAddress emailAddress;
|
||||
@@ -41,7 +41,7 @@ public class AccountDialog extends Dialog<Account> {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public AccountDialog() {
|
||||
public TestMainFxAccountDialog() {
|
||||
super();
|
||||
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("accountdialog.fxml"));
|
||||
@@ -65,12 +65,12 @@ public class AccountDialog extends Dialog<Account> {
|
||||
|
||||
private void setResultConverter() {
|
||||
System.out.println("setResultConverter called.");
|
||||
Callback<ButtonType, Account> accountResultConverter = (buttonType) -> {
|
||||
if (buttonType == ButtonType.OK) {
|
||||
Callback<ButtonType, Account> aRC = (buttonType) -> {
|
||||
if (buttonType == ButtonType.OK && mailingAddress != null && getEmailAddress().getEmail_address().trim().length() > 0 && getPhoneNumber().trim().length() > 0) {
|
||||
return new Account(phoneNumber, mailingAddress, emailAddress);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
setResultConverter(accountResultConverter);
|
||||
setResultConverter(aRC);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,65 @@
|
||||
package lodge;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.Button;
|
||||
import lodge.datamodel.Account;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import lodge.datamodel.Address;
|
||||
|
||||
public class TestMainFxCommandButtonEventController {
|
||||
|
||||
@FXML
|
||||
private Button btnAdd;
|
||||
|
||||
@FXML
|
||||
private TableView tvInventory;
|
||||
|
||||
private final ObservableList<Address> rows = FXCollections.observableArrayList();
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
|
||||
rows.add(new Address("10 wilco ave", "wilco", "WY", "82801"));
|
||||
rows.add(new Address("30 Amstadam ave", "New York", "NY", "12010"));
|
||||
rows.add(new Address("400 hotel ave", "Maryland City", "MD", "20723"));
|
||||
|
||||
TableColumn<Address, String> tcStreet = new TableColumn<>("Street");
|
||||
TableColumn<Address, String> tcCity = new TableColumn<>("City");
|
||||
TableColumn<Address, String> tcState = new TableColumn<>("State");
|
||||
TableColumn<Address, String> tcZip = new TableColumn<>("Zip");
|
||||
|
||||
tcStreet.setPrefWidth( 100.0d );
|
||||
tcStreet.setMinWidth(100.0d);
|
||||
tcCity.setPrefWidth( 100.0d );
|
||||
tcState.setPrefWidth( 100.0d );
|
||||
tcZip.setPrefWidth( 100.0d );
|
||||
|
||||
tcStreet.setCellValueFactory(new PropertyValueFactory<Address, String>("street"));
|
||||
tcCity.setCellValueFactory(new PropertyValueFactory<Address, String>("city"));
|
||||
tcState.setCellValueFactory(new PropertyValueFactory<Address, String>("state"));
|
||||
tcZip.setCellValueFactory(new PropertyValueFactory<Address, String>("zip"));
|
||||
|
||||
tvInventory.itemsProperty().bind( new SimpleObjectProperty<>(rows) );
|
||||
tvInventory.getColumns().clear();
|
||||
tvInventory.getColumns().addAll(tcStreet, tcCity, tcState, tcZip);
|
||||
|
||||
|
||||
btnAdd.setOnAction((ev) -> {
|
||||
|
||||
AccountDialog accomodationDialog= new AccountDialog();
|
||||
|
||||
TestMainFxAccountDialog accomodationDialog = new TestMainFxAccountDialog();
|
||||
|
||||
Optional result = accomodationDialog.showAndWait();
|
||||
|
||||
if( result.isPresent()){
|
||||
if (result.isPresent()) {
|
||||
System.out.println("result is present.");
|
||||
// add to storage
|
||||
// bind to model
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public final class Address{
|
||||
/** not used
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private Address() {
|
||||
|
||||
public Address() {
|
||||
}
|
||||
|
||||
public Address(String street, String city, String state, String zip) {
|
||||
|
||||
@@ -36,8 +36,9 @@
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ButtonBar?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.SplitPane?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
@@ -46,7 +47,7 @@
|
||||
<?import javafx.scene.paint.Color?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<VBox fx:controller="lodge.TestMainFxCommandButtonEventController" prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/24.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<VBox prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/24.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="lodge.TestMainFxCommandButtonEventController">
|
||||
<children>
|
||||
<SplitPane dividerPositions="0.11469933184855234" focusTraversable="true" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
||||
<items>
|
||||
@@ -88,7 +89,14 @@
|
||||
<TextField prefHeight="31.0" prefWidth="314.0" promptText="search" />
|
||||
</children>
|
||||
</HBox>
|
||||
<ListView prefHeight="536.0" prefWidth="761.0" />
|
||||
<TableView fx:id="tvInventory" prefHeight="501.0" prefWidth="761.0">
|
||||
<columns>
|
||||
<TableColumn prefWidth="75.0" text="Street" />
|
||||
<TableColumn prefWidth="75.0" text="City" />
|
||||
<TableColumn prefWidth="75.0" text="State" />
|
||||
<TableColumn prefWidth="75.0" text="Zip" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user