Skip to content

Commit

Permalink
fix dependency and async load
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinayagarwal committed Aug 14, 2024
1 parent 1802c8d commit 3312192
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
5 changes: 3 additions & 2 deletions samples/introduction/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>20</javafx.version>
<emoji.version>1.0.2-SNAPSHOT</emoji.version>
<javafx.plugin.version>0.0.8</javafx.plugin.version>
<gluonfx.plugin.version>1.0.19</gluonfx.plugin.version>
<main.class>com.gluonhq.sample.Main</main.class>
Expand All @@ -27,9 +28,9 @@
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq</groupId>
<groupId>com.gluonhq.emoji</groupId>
<artifactId>emoji</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>${emoji.version}</version>
</dependency>
</dependencies>

Expand Down
31 changes: 15 additions & 16 deletions samples/introduction/src/main/java/com/gluonhq/sample/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Node> nodes = TextUtils.convertToTextAndImageNodes(unicodeText);
Platform.runLater(() -> hBox.getChildren().setAll(nodes));
});
String unicodeText = createUnicodeText(newValue);
List<Node> 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) {
Expand Down

0 comments on commit 3312192

Please sign in to comment.