From b3496dc181a926b0b1617794674f266989a81497 Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Tue, 12 Dec 2017 13:59:53 +0100 Subject: [PATCH] implementation de a barre de recherche --- controller/RootLayout.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/controller/RootLayout.java b/controller/RootLayout.java index c7e4b57..fd59cd1 100644 --- a/controller/RootLayout.java +++ b/controller/RootLayout.java @@ -13,10 +13,16 @@ import Classes.css.user.SubMenuStyleSheet; import Interfaces.Event; import Interfaces.EventObserver; import javafx.application.Application; +import javafx.application.Platform; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.Scene; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.FlowPane; @@ -143,6 +149,31 @@ public class RootLayout extends Application implements EventObserver { if(NewsListModel.getInstance().getNews().size() != 0) { this.articles.clearContent(); + + TextField tx = new TextField(); + tx.setPromptText("search..."); + tx.setId("mag_searchbar"); + tx.setOnKeyPressed(new EventHandler() { + + @Override + public void handle(KeyEvent arg0) { + if(arg0.getCode() == KeyCode.ENTER) { + NewsListModel.getInstance().query(tx.textProperty().get()); + } + + } + + }); + + Platform.runLater(new Runnable() { + + @Override + public void run() { + RootLayout.this.main_container.getChildren().add(tx); + + } + + }); // For each news for( NewsModel news : NewsListModel.getInstance().getNews() ){