From 58a6b7ecd8d6d991a4c8413d30cde639a1d20afd Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 24 Oct 2020 13:21:09 +0300 Subject: [PATCH] lab-04/NewAccount: - method that returns defualt hbox of app. used in all others. --- lab-04/NewAccount/src/sample/Main.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lab-04/NewAccount/src/sample/Main.java b/lab-04/NewAccount/src/sample/Main.java index cae5551..2279b07 100644 --- a/lab-04/NewAccount/src/sample/Main.java +++ b/lab-04/NewAccount/src/sample/Main.java @@ -46,7 +46,7 @@ public class Main extends Application { HBox boxLasttName = makeLebelWithText("Last name: "); HBox boxPassword = makeLebelWithText("Enter password"); HBox boxRePass = makeLebelWithText("Reenter password: "); - HBox boxCity = makeLebelWithText("City"); + HBox boxCity = makeLebelWithText("City: "); HBox boxCountry = makeComboBoxWithLabel("Choose a country: "); HBox boxButtons = makeButtons(); @@ -69,9 +69,7 @@ public class Main extends Application { } private HBox makeLebelWithText(String labelText){ - HBox node = new HBox(); - node.setPadding(new Insets(10)); - node.setSpacing(10); + HBox node = getStdHBox(); Label label = new Label(labelText); TextField textField = new TextField(); node.getChildren().addAll(label, textField); @@ -79,19 +77,14 @@ public class Main extends Application { } private HBox makeComboBoxWithLabel(String labelText) { - HBox node = new HBox(); - node.setPadding(new Insets(10)); - node.setSpacing(10); + HBox node = getStdHBox(); Label label = new Label(labelText); node.getChildren().addAll(label, new ComboBox<>(FXCollections.observableArrayList(Countries))); return node; } private HBox makeButtons(){ - HBox node = new HBox(); - node.setPadding(new Insets(10)); - node.setSpacing(10); - node.setAlignment(Pos.CENTER); + HBox node = getStdHBox(); Button bClear = new Button("Clear"); Button bRegister = new Button("Register"); bClear.setPrefSize(100, 20); @@ -100,4 +93,12 @@ public class Main extends Application { return node; } + private HBox getStdHBox() { + HBox node = new HBox(); + node.setPadding(new Insets(10)); + node.setSpacing(10); + node.setAlignment(Pos.CENTER); + return node; + } + }