From e004e6fdb78f201a4d5a9b20237d0e88a9d0333d Mon Sep 17 00:00:00 2001 From: Ivan Olexyn Date: Sat, 7 Mar 2020 17:27:21 +0100 Subject: [PATCH] UI styling done. --- src/com/olexyn/ensync/Controller.java | 39 ++++++++++++------------ src/com/olexyn/ensync/Main.java | 2 +- src/com/olexyn/ensync/layout.fxml | 44 +++++++++++++-------------- 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/com/olexyn/ensync/Controller.java b/src/com/olexyn/ensync/Controller.java index fa5fc78..ac9d56b 100644 --- a/src/com/olexyn/ensync/Controller.java +++ b/src/com/olexyn/ensync/Controller.java @@ -1,7 +1,6 @@ package com.olexyn.ensync; -import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.Node; @@ -9,6 +8,7 @@ import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.GridPane; +import javafx.scene.text.Text; import javafx.stage.DirectoryChooser; import javafx.stage.Window; @@ -24,8 +24,6 @@ import java.util.ResourceBundle; public class Controller implements Initializable { - - @Override public void initialize(URL url, ResourceBundle resourceBundle) { @@ -39,22 +37,23 @@ public class Controller implements Initializable { addDirButton.setOnAction(event -> { this.addDir();}); gridPane.add(directoryField, 0, 0); - gridPane.add(addDirButton, 1, 0); + gridPane.add(new Text(""), 1, 0); + gridPane.add(new Text(""), 2, 0); + gridPane.add(new Text(""), 3, 0); + gridPane.add(addDirButton, 4, 0); } - @FXML - protected AnchorPane anchor; + @FXML protected GridPane gridPane; - protected void addDir() { - Window stage = anchor.getScene().getWindow(); + Window stage = gridPane.getScene().getWindow(); final DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setTitle("Select Directory."); @@ -68,11 +67,15 @@ public class Controller implements Initializable { pathTextField.setText(dir.getAbsolutePath()); pathTextField.setDisable(true); + TextField stateTextField = new TextField(); + stateTextField.setText("STATE"); - Button removeButton = new Button("Remove"); - removeButton.setId("removeButton"+ dir.getAbsolutePath()); + stateTextField.setStyle("-fx-text-fill: green"); + stateTextField.setDisable(true); + Button removeButton = new Button("Remove"); + removeButton.setId("removeButton" + dir.getAbsolutePath()); List nodeList = new ArrayList<>(); @@ -80,16 +83,15 @@ public class Controller implements Initializable { nodeList.addAll(gridPane.getChildren()); - - - - for (Node node : nodeList) { if (node.getId() != null && node.getId().equals("directoryField")) { int i = nodeList.indexOf(node); nodeList.add(i, removeButton); + nodeList.add(i, new Text("")); + nodeList.add(i, stateTextField); + nodeList.add(i, new Text("")); nodeList.add(i, pathTextField); break; } @@ -100,19 +102,18 @@ public class Controller implements Initializable { int col = 0; int row = 0; - for(Node node : nodeList){ + for (Node node : nodeList) { - gridPane.add(node, col,row); + gridPane.add(node, col, row); col++; - if (nodeList.indexOf(node)%2==1){ + if (nodeList.indexOf(node) % 5 == 4) { row++; - col=0; + col = 0; } } - } diff --git a/src/com/olexyn/ensync/Main.java b/src/com/olexyn/ensync/Main.java index 54ef873..8acbc28 100644 --- a/src/com/olexyn/ensync/Main.java +++ b/src/com/olexyn/ensync/Main.java @@ -24,7 +24,7 @@ public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("layout.fxml")); - Scene scene = new Scene(root, 430, 500); + Scene scene = new Scene(root, 500, 500); diff --git a/src/com/olexyn/ensync/layout.fxml b/src/com/olexyn/ensync/layout.fxml index f4bdfed..7e3dd15 100644 --- a/src/com/olexyn/ensync/layout.fxml +++ b/src/com/olexyn/ensync/layout.fxml @@ -6,26 +6,24 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +