UI styling done.

pull/1/head
Ivan Olexyn 5 years ago
parent a86a7eb550
commit e004e6fdb7

@ -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<Node> 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;
}
}
}

@ -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);

@ -6,26 +6,24 @@
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="anchor" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.olexyn.ensync.Controller">
<children>
<ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="400.0" prefWidth="600.0">
<ScrollPane fitToHeight="true" fitToWidth="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="394.0" prefWidth="672.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.olexyn.ensync.Controller">
<content>
<GridPane fx:id="gridPane">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints halignment="LEFT" hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="200.0" prefWidth="200.0" />
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="NEVER" maxWidth="20.0" minWidth="20.0" prefWidth="20.0" />
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="NEVER" maxWidth="100.0" minWidth="100.0" prefWidth="100.0" />
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="NEVER" maxWidth="20.0" minWidth="20.0" prefWidth="20.0" />
<ColumnConstraints fillWidth="false" halignment="LEFT" hgrow="NEVER" maxWidth="200.0" minWidth="200.0" prefWidth="200.0" />
</columnConstraints>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
</rowConstraints>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</GridPane>
</content>
</ScrollPane>
</children>
</AnchorPane>
</ScrollPane>

Loading…
Cancel
Save