Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| restricted:mco-2:correction:tp4 [2016/03/30 10:35] – fbrucker | restricted:mco-2:correction:tp4 [2016/03/30 12:58] (Version actuelle) – fbrucker | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | ====== Correction TP4 ====== | ||
| + | |||
| + | ===== MVC ===== | ||
| + | |||
| + | Seuls UserInterface et Controller ont changé. On a mis en place des getter dans UserInterface et ont les a utilisés dans le contrôleur. | ||
| + | |||
| + | === UserInterface.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.control.Button; | ||
| + | import javafx.scene.control.TextField; | ||
| + | import javafx.scene.layout.HBox; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | public class UserInterface { | ||
| + | private Group root; | ||
| + | |||
| + | private TextField todoItemInput; | ||
| + | private Button addButton; | ||
| + | |||
| + | public UserInterface() { | ||
| + | root = generateUI(); | ||
| + | } | ||
| + | |||
| + | private Group generateUI() { | ||
| + | Group uiRoot = new Group(); | ||
| + | |||
| + | HBox hBox = new HBox(10); | ||
| + | uiRoot.getChildren().add(hBox); | ||
| + | |||
| + | Text text = new Text(" | ||
| + | todoItemInput = new TextField(); | ||
| + | addButton = new Button(" | ||
| + | |||
| + | hBox.getChildren().addAll(text, | ||
| + | |||
| + | return uiRoot; | ||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | |||
| + | public TextField getTodoItemInput() { | ||
| + | return todoItemInput; | ||
| + | } | ||
| + | |||
| + | public Button getAddButton() { | ||
| + | return addButton; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | === Controller.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.event.ActionEvent; | ||
| + | import javafx.scene.control.Button; | ||
| + | |||
| + | import java.util.ArrayList; | ||
| + | |||
| + | public class Controller { | ||
| + | private ArrayList< | ||
| + | private UserInterface vue; | ||
| + | |||
| + | public Controller(ArrayList< | ||
| + | this.model = model; | ||
| + | this.vue = vue; | ||
| + | |||
| + | Button button = vue.getAddButton(); | ||
| + | |||
| + | button.setOnAction(this:: | ||
| + | } | ||
| + | |||
| + | private void handleButtonAdd(ActionEvent actionEvent) { | ||
| + | String todoItemText = vue.getTodoItemInput().getText(); | ||
| + | if (!todoItemText.equals("" | ||
| + | model.add(todoItemText); | ||
| + | } | ||
| + | | ||
| + | System.out.println(model); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Amélioration de UI ===== | ||
| + | |||
| + | Javafx 8 permet de faire de nombreux agencements de composants graphique, lisez par exemple ce [[http:// | ||
| + | |||
| + | ==== Représentez le modèle ==== | ||
| + | |||
| + | On a ajouté un champ contenant notre liste dans la vue et on l'a utilisé dans le contrôleur. | ||
| + | |||
| + | === UserInterface.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.control.Button; | ||
| + | import javafx.scene.control.ScrollPane; | ||
| + | import javafx.scene.control.TextField; | ||
| + | import javafx.scene.layout.HBox; | ||
| + | import javafx.scene.layout.VBox; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | public class UserInterface { | ||
| + | private Group root; | ||
| + | |||
| + | private TextField todoItemInput; | ||
| + | private Button addButton; | ||
| + | private VBox todoItemList; | ||
| + | |||
| + | public UserInterface() { | ||
| + | root = generateUI(); | ||
| + | } | ||
| + | |||
| + | private Group generateUI() { | ||
| + | Group uiRoot = new Group(); | ||
| + | |||
| + | HBox hBox = new HBox(10); | ||
| + | |||
| + | |||
| + | Text text = new Text(" | ||
| + | todoItemInput = new TextField(); | ||
| + | addButton = new Button(" | ||
| + | |||
| + | hBox.getChildren().addAll(text, | ||
| + | |||
| + | VBox vBox = new VBox(20); | ||
| + | |||
| + | todoItemList = new VBox(5); | ||
| + | ScrollPane scrollPane = new ScrollPane(); | ||
| + | scrollPane.setContent(todoItemList); | ||
| + | scrollPane.setPrefSize(200, | ||
| + | |||
| + | vBox.getChildren().add(hBox); | ||
| + | vBox.getChildren().add(scrollPane); | ||
| + | |||
| + | uiRoot.getChildren().add(vBox); | ||
| + | |||
| + | return uiRoot; | ||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | |||
| + | public TextField getTodoItemInput() { | ||
| + | return todoItemInput; | ||
| + | } | ||
| + | |||
| + | public Button getAddButton() { | ||
| + | return addButton; | ||
| + | } | ||
| + | |||
| + | public VBox getTodoItemList() { | ||
| + | return todoItemList; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === Controller.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.event.ActionEvent; | ||
| + | import javafx.scene.control.Button; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | import java.util.ArrayList; | ||
| + | |||
| + | public class Controller { | ||
| + | private ArrayList< | ||
| + | private UserInterface vue; | ||
| + | |||
| + | public Controller(ArrayList< | ||
| + | this.model = model; | ||
| + | this.vue = vue; | ||
| + | |||
| + | Button button = vue.getAddButton(); | ||
| + | |||
| + | button.setOnAction(this:: | ||
| + | } | ||
| + | |||
| + | private void handleButtonAdd(ActionEvent actionEvent) { | ||
| + | String todoItemText = vue.getTodoItemInput().getText(); | ||
| + | if (!todoItemText.equals("" | ||
| + | model.add(todoItemText); | ||
| + | vue.getTodoItemList().getChildren().add(new Text(todoItemText)); | ||
| + | } | ||
| + | |||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Ajout du résumé ==== | ||
| + | |||
| + | === UserInterface.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.control.Button; | ||
| + | import javafx.scene.control.ScrollPane; | ||
| + | import javafx.scene.control.TextField; | ||
| + | import javafx.scene.layout.HBox; | ||
| + | import javafx.scene.layout.VBox; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | public class UserInterface { | ||
| + | private Group root; | ||
| + | |||
| + | private TextField todoItemInput; | ||
| + | private Button addButton; | ||
| + | private VBox todoItemList; | ||
| + | private Text totalItem; | ||
| + | private int numberTotalItem; | ||
| + | |||
| + | public UserInterface() { | ||
| + | numberTotalItem = 0; | ||
| + | root = generateUI(); | ||
| + | } | ||
| + | |||
| + | private Group generateUI() { | ||
| + | Group uiRoot = new Group(); | ||
| + | |||
| + | HBox hBox = new HBox(10); | ||
| + | |||
| + | |||
| + | Text text = new Text(" | ||
| + | todoItemInput = new TextField(); | ||
| + | addButton = new Button(" | ||
| + | |||
| + | hBox.getChildren().addAll(text, | ||
| + | |||
| + | VBox vBox = new VBox(20); | ||
| + | |||
| + | todoItemList = new VBox(5); | ||
| + | ScrollPane scrollPane = new ScrollPane(); | ||
| + | scrollPane.setContent(todoItemList); | ||
| + | scrollPane.setPrefSize(200, | ||
| + | |||
| + | vBox.getChildren().add(hBox); | ||
| + | vBox.getChildren().add(scrollPane); | ||
| + | |||
| + | totalItem = new Text(); | ||
| + | text = new Text(" | ||
| + | HBox hBoxNumberItem = new HBox(10); | ||
| + | hBoxNumberItem.getChildren().addAll(text, | ||
| + | |||
| + | totalItem.setText(String.valueOf(numberTotalItem)); | ||
| + | vBox.getChildren().add(hBoxNumberItem); | ||
| + | |||
| + | uiRoot.getChildren().add(vBox); | ||
| + | |||
| + | return uiRoot; | ||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | |||
| + | public TextField getTodoItemInput() { | ||
| + | return todoItemInput; | ||
| + | } | ||
| + | |||
| + | public Button getAddButton() { | ||
| + | return addButton; | ||
| + | } | ||
| + | |||
| + | public VBox getTodoItemList() { | ||
| + | return todoItemList; | ||
| + | } | ||
| + | |||
| + | public void setNumberTotalItem(int numberTotalItem) { | ||
| + | this.numberTotalItem = numberTotalItem; | ||
| + | totalItem.setText(String.valueOf(numberTotalItem)); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === Controller.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.event.ActionEvent; | ||
| + | import javafx.scene.control.Button; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | import java.util.ArrayList; | ||
| + | |||
| + | public class Controller { | ||
| + | private ArrayList< | ||
| + | private UserInterface vue; | ||
| + | |||
| + | public Controller(ArrayList< | ||
| + | this.model = model; | ||
| + | this.vue = vue; | ||
| + | |||
| + | Button button = vue.getAddButton(); | ||
| + | |||
| + | button.setOnAction(this:: | ||
| + | } | ||
| + | |||
| + | private void handleButtonAdd(ActionEvent actionEvent) { | ||
| + | String todoItemText = vue.getTodoItemInput().getText(); | ||
| + | if (!todoItemText.equals("" | ||
| + | model.add(todoItemText); | ||
| + | vue.getTodoItemList().getChildren().add(new Text(todoItemText)); | ||
| + | vue.setNumberTotalItem(model.size()); | ||
| + | } | ||
| + | |||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Mise à jour du modèle ===== | ||
| + | |||
| + | === Main.java === | ||
| + | |||
| + | <code Java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.application.Application; | ||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.Scene; | ||
| + | import javafx.stage.Stage; | ||
| + | |||
| + | import java.util.ArrayList; | ||
| + | |||
| + | public class Main extends Application { | ||
| + | |||
| + | public static void main(String[] args) { | ||
| + | launch(args); | ||
| + | } | ||
| + | |||
| + | |||
| + | @Override | ||
| + | public void start(Stage primaryStage) throws Exception { | ||
| + | // on met en place la racine de la scène | ||
| + | Group root = new Group(); | ||
| + | Scene theScene = new Scene(root); | ||
| + | primaryStage.setScene(theScene); | ||
| + | |||
| + | |||
| + | //Vue | ||
| + | UserInterface userInterface = new UserInterface(); | ||
| + | root.getChildren().add(userInterface.getRoot()); | ||
| + | |||
| + | //Modèle | ||
| + | ArrayList< | ||
| + | |||
| + | // | ||
| + | Controller controller = new Controller(todoList, | ||
| + | |||
| + | //Affichage de l'UI | ||
| + | primaryStage.setTitle(" | ||
| + | primaryStage.show(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | === TodoItem.java === | ||
| + | |||
| + | <code Java> | ||
| + | package com.mco; | ||
| + | |||
| + | import java.util.Date; | ||
| + | |||
| + | |||
| + | public class TodoItem { | ||
| + | private String name; | ||
| + | private Date creation; | ||
| + | |||
| + | public TodoItem(String name) { | ||
| + | this.name = name; | ||
| + | creation = new Date(); | ||
| + | } | ||
| + | |||
| + | public String getName() { | ||
| + | return name; | ||
| + | } | ||
| + | |||
| + | public Date getCreation() { | ||
| + | return creation; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === UserIterface.java === | ||
| + | |||
| + | <code Java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.control.Button; | ||
| + | import javafx.scene.control.ScrollPane; | ||
| + | import javafx.scene.control.TextField; | ||
| + | import javafx.scene.layout.HBox; | ||
| + | import javafx.scene.layout.VBox; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | public class UserInterface { | ||
| + | private Group root; | ||
| + | |||
| + | private TextField todoItemInput; | ||
| + | private Button addButton; | ||
| + | private VBox todoItemList; | ||
| + | private Text totalItem; | ||
| + | private int numberTotalItem; | ||
| + | |||
| + | public UserInterface() { | ||
| + | numberTotalItem = 0; | ||
| + | root = generateUI(); | ||
| + | } | ||
| + | |||
| + | private Group generateUI() { | ||
| + | Group uiRoot = new Group(); | ||
| + | |||
| + | HBox hBox = new HBox(10); | ||
| + | |||
| + | |||
| + | Text text = new Text(" | ||
| + | todoItemInput = new TextField(); | ||
| + | addButton = new Button(" | ||
| + | |||
| + | hBox.getChildren().addAll(text, | ||
| + | |||
| + | VBox vBox = new VBox(20); | ||
| + | |||
| + | todoItemList = new VBox(5); | ||
| + | ScrollPane scrollPane = new ScrollPane(); | ||
| + | scrollPane.setContent(todoItemList); | ||
| + | scrollPane.setPrefSize(300, | ||
| + | |||
| + | vBox.getChildren().add(hBox); | ||
| + | vBox.getChildren().add(scrollPane); | ||
| + | |||
| + | totalItem = new Text(); | ||
| + | text = new Text(" | ||
| + | HBox hBoxNumberItem = new HBox(10); | ||
| + | hBoxNumberItem.getChildren().addAll(text, | ||
| + | |||
| + | totalItem.setText(String.valueOf(numberTotalItem)); | ||
| + | vBox.getChildren().add(hBoxNumberItem); | ||
| + | |||
| + | uiRoot.getChildren().add(vBox); | ||
| + | |||
| + | return uiRoot; | ||
| + | } | ||
| + | |||
| + | public void addTodoItem(TodoItem item) { | ||
| + | HBox hBox = new HBox(20); | ||
| + | hBox.getChildren().addAll(new Text(item.getName()), | ||
| + | new Text(item.getCreation().toString())); | ||
| + | |||
| + | todoItemList.getChildren().add(hBox); | ||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | |||
| + | public TextField getTodoItemInput() { | ||
| + | return todoItemInput; | ||
| + | } | ||
| + | |||
| + | public Button getAddButton() { | ||
| + | return addButton; | ||
| + | } | ||
| + | |||
| + | public VBox getTodoItemList() { | ||
| + | return todoItemList; | ||
| + | } | ||
| + | |||
| + | public void setNumberTotalItem(int numberTotalItem) { | ||
| + | this.numberTotalItem = numberTotalItem; | ||
| + | totalItem.setText(String.valueOf(numberTotalItem)); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === Controller.java === | ||
| + | |||
| + | <code Java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.event.ActionEvent; | ||
| + | import javafx.scene.control.Button; | ||
| + | |||
| + | import java.util.ArrayList; | ||
| + | |||
| + | public class Controller { | ||
| + | private ArrayList< | ||
| + | private UserInterface vue; | ||
| + | |||
| + | public Controller(ArrayList< | ||
| + | this.model = model; | ||
| + | this.vue = vue; | ||
| + | |||
| + | Button button = vue.getAddButton(); | ||
| + | |||
| + | button.setOnAction(this:: | ||
| + | } | ||
| + | |||
| + | private void handleButtonAdd(ActionEvent actionEvent) { | ||
| + | String todoItemText = vue.getTodoItemInput().getText(); | ||
| + | if (!todoItemText.equals("" | ||
| + | TodoItem item = new TodoItem(todoItemText); | ||
| + | model.add(item); | ||
| + | vue.addTodoItem(item); | ||
| + | |||
| + | vue.setNumberTotalItem(model.size()); | ||
| + | } | ||
| + | |||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Mise à jour de la vue ===== | ||
| + | |||
| + | Seul UserInterface a été impacté. | ||
| + | |||
| + | === UserInterface.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.control.Button; | ||
| + | import javafx.scene.control.TextField; | ||
| + | import javafx.scene.layout.VBox; | ||
| + | |||
| + | public class UserInterface { | ||
| + | private Group root; | ||
| + | |||
| + | private InputTodoItemUI inputTodoItemUI; | ||
| + | private TodoListUI todoListUI; | ||
| + | private SummaryUI summaryUI; | ||
| + | |||
| + | public UserInterface() { | ||
| + | root = generateUI(); | ||
| + | } | ||
| + | |||
| + | private Group generateUI() { | ||
| + | Group uiRoot = new Group(); | ||
| + | VBox vBox = new VBox(20); | ||
| + | |||
| + | inputTodoItemUI = new InputTodoItemUI(); | ||
| + | todoListUI = new TodoListUI(); | ||
| + | summaryUI = new SummaryUI(); | ||
| + | |||
| + | vBox.getChildren().addAll( | ||
| + | inputTodoItemUI.getRoot(), | ||
| + | todoListUI.getRoot(), | ||
| + | summaryUI.getRoot() | ||
| + | ); | ||
| + | |||
| + | uiRoot.getChildren().add(vBox); | ||
| + | |||
| + | return uiRoot; | ||
| + | } | ||
| + | |||
| + | public void addTodoItem(TodoItem item) { | ||
| + | todoListUI.addTodoItem(item); | ||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | |||
| + | public TextField getTodoItemInput() { | ||
| + | return inputTodoItemUI.getTodoItemInput(); | ||
| + | } | ||
| + | |||
| + | public Button getAddButton() { | ||
| + | return inputTodoItemUI.getAddButton(); | ||
| + | } | ||
| + | |||
| + | public void setNumberTotalItem(int numberTotalItem) { | ||
| + | summaryUI.setNumberTotalItem(numberTotalItem); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === InputTodoItemUI.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.control.Button; | ||
| + | import javafx.scene.control.TextField; | ||
| + | import javafx.scene.layout.HBox; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | |||
| + | public class InputTodoItemUI { | ||
| + | |||
| + | private Group root; | ||
| + | private TextField todoItemInput; | ||
| + | private Button addButton; | ||
| + | |||
| + | public InputTodoItemUI() { | ||
| + | root = new Group(); | ||
| + | HBox hBox = new HBox(10); | ||
| + | |||
| + | |||
| + | Text text = new Text(" | ||
| + | todoItemInput = new TextField(); | ||
| + | addButton = new Button(" | ||
| + | |||
| + | hBox.getChildren().addAll(text, | ||
| + | |||
| + | root.getChildren().add(hBox); | ||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | |||
| + | public TextField getTodoItemInput() { | ||
| + | return todoItemInput; | ||
| + | } | ||
| + | |||
| + | public Button getAddButton() { | ||
| + | return addButton; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === TodoListUI.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.control.ScrollPane; | ||
| + | import javafx.scene.layout.VBox; | ||
| + | |||
| + | public class TodoListUI { | ||
| + | private Group root; | ||
| + | private VBox todoItemList; | ||
| + | |||
| + | public TodoListUI() { | ||
| + | root = new Group(); | ||
| + | todoItemList = new VBox(5); | ||
| + | ScrollPane scrollPane = new ScrollPane(); | ||
| + | scrollPane.setContent(todoItemList); | ||
| + | scrollPane.setPrefSize(300, | ||
| + | |||
| + | root.getChildren().add(scrollPane); | ||
| + | } | ||
| + | |||
| + | public void addTodoItem(TodoItem item) { | ||
| + | TodoItemUI todoItemUI = new TodoItemUI(item); | ||
| + | todoItemList.getChildren().add(todoItemUI.getRoot()); | ||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === TodoItemUI.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.layout.HBox; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | public class TodoItemUI { | ||
| + | private Group root; | ||
| + | public TodoItemUI(TodoItem item) { | ||
| + | root = new Group(); | ||
| + | |||
| + | HBox hBox = new HBox(20); | ||
| + | hBox.getChildren().addAll( | ||
| + | new Text(item.getName()), | ||
| + | new Text(item.getCreation().toString()) | ||
| + | ); | ||
| + | root.getChildren().add(hBox); | ||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === SummaryUI.java === | ||
| + | |||
| + | <code java> | ||
| + | package com.mco; | ||
| + | |||
| + | |||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.layout.HBox; | ||
| + | import javafx.scene.text.Text; | ||
| + | |||
| + | public class SummaryUI { | ||
| + | private Group root; | ||
| + | private Text totalItem; | ||
| + | private int numberTotalItem; | ||
| + | |||
| + | public SummaryUI() { | ||
| + | root = new Group(); | ||
| + | |||
| + | numberTotalItem = 0; | ||
| + | totalItem = new Text(); | ||
| + | Text text = new Text(" | ||
| + | HBox hBoxNumberItem = new HBox(10); | ||
| + | hBoxNumberItem.getChildren().addAll(text, | ||
| + | |||
| + | totalItem.setText(String.valueOf(numberTotalItem)); | ||
| + | |||
| + | root.getChildren().add(hBoxNumberItem); | ||
| + | |||
| + | } | ||
| + | |||
| + | public Group getRoot() { | ||
| + | return root; | ||
| + | } | ||
| + | public void setNumberTotalItem(int numberTotalItem) { | ||
| + | this.numberTotalItem = numberTotalItem; | ||
| + | totalItem.setText(String.valueOf(numberTotalItem)); | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | </ | ||