Example usage for javafx.scene.control Label setBackground

List of usage examples for javafx.scene.control Label setBackground

Introduction

In this page you can find the example usage for javafx.scene.control Label setBackground.

Prototype

public final void setBackground(Background value) 

Source Link

Usage

From source file:ui.main.MainViewController.java

private synchronized void paintDate(Chat chat, String day) {
    //this method draws the recievied text message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override//from   w  w  w  .  j  a va  2  s  .co m
        protected HBox call() throws Exception {

            VBox vbox = new VBox(); //to add text

            //chat message
            Label l = new Label(day);
            l.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, null, null)));

            HBox hbox = new HBox();
            hbox.setAlignment(Pos.CENTER);
            hbox.getChildren().addAll(l);
            return hbox;
        }
    };

    recievedMessages.setOnSucceeded(event -> {
        chatList.getChildren().add(recievedMessages.getValue());

    });

    if (chat.getParticipant().contains(currentChat.getParticipant())) {
        Thread t = new Thread(recievedMessages);
        try {
            t.join();
        } catch (InterruptedException ex) {
            Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }
        //t.setDaemon(true);
        t.start();
        scrollPane.setVvalue(scrollPane.getHmax());
    }
}