From 3312192e39fb91d8de86f786cc75bc6826f70a7b Mon Sep 17 00:00:00 2001 From: Abhinay Agarwal Date: Wed, 14 Aug 2024 13:05:20 +0530 Subject: [PATCH] fix dependency and async load --- samples/introduction/pom.xml | 5 +-- .../main/java/com/gluonhq/sample/Main.java | 31 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/samples/introduction/pom.xml b/samples/introduction/pom.xml index b285778..8bc6356 100644 --- a/samples/introduction/pom.xml +++ b/samples/introduction/pom.xml @@ -15,6 +15,7 @@ UTF-8 11 20 + 1.0.2-SNAPSHOT 0.0.8 1.0.19 com.gluonhq.sample.Main @@ -27,9 +28,9 @@ ${javafx.version} - com.gluonhq + com.gluonhq.emoji emoji - 1.0.2-SNAPSHOT + ${emoji.version} diff --git a/samples/introduction/src/main/java/com/gluonhq/sample/Main.java b/samples/introduction/src/main/java/com/gluonhq/sample/Main.java index 0529207..0c44390 100644 --- a/samples/introduction/src/main/java/com/gluonhq/sample/Main.java +++ b/samples/introduction/src/main/java/com/gluonhq/sample/Main.java @@ -25,30 +25,29 @@ public class Main extends Application { @Override public void start(Stage stage) { - VBox root = createRoot(); - root.setAlignment(Pos.TOP_CENTER); - - Scene scene = new Scene(root, 300, 200); - scene.getStylesheets().add(Main.class.getResource("styles.css").toExternalForm()); - stage.setScene(scene); - stage.show(); - } - - private VBox createRoot() { TextArea textArea = new TextArea(); textArea.setPrefHeight(150); HBox hBox = new HBox(); + VBox root = new VBox(20, textArea, hBox); + root.setAlignment(Pos.TOP_CENTER); + root.setDisable(true); textArea.textProperty().addListener((o, oldValue, newValue) -> { if (newValue != null && !newValue.isEmpty()) { - EmojiLoaderFactory.getEmojiImageLoader().initialize().thenAccept(aBoolean -> { - String unicodeText = createUnicodeText(newValue); - List nodes = TextUtils.convertToTextAndImageNodes(unicodeText); - Platform.runLater(() -> hBox.getChildren().setAll(nodes)); - }); + String unicodeText = createUnicodeText(newValue); + List nodes = TextUtils.convertToTextAndImageNodes(unicodeText); + hBox.getChildren().setAll(nodes); } }); - return new VBox(20, textArea, hBox); + + EmojiLoaderFactory.getEmojiImageLoader().initialize().thenAccept(aBoolean -> { + root.setDisable(false); + }); + + Scene scene = new Scene(root, 300, 200); + scene.getStylesheets().add(Main.class.getResource("styles.css").toExternalForm()); + stage.setScene(scene); + stage.show(); } private String createUnicodeText(String nv) {