Example usage for javafx.scene.layout BackgroundFill BackgroundFill

List of usage examples for javafx.scene.layout BackgroundFill BackgroundFill

Introduction

In this page you can find the example usage for javafx.scene.layout BackgroundFill BackgroundFill.

Prototype

public BackgroundFill(@NamedArg("fill") Paint fill, @NamedArg("radii") CornerRadii radii,
        @NamedArg("insets") Insets insets) 

Source Link

Document

Creates a new BackgroundFill with the specified fill, radii, and insets.

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/*  www.jav  a 2  s . c o  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());
    }
}

From source file:ui.main.MainViewController.java

private synchronized void paintReceivedMessage(Chat chat, String msg, String time) {
    //this method draws the recievied text message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override/*from w w w  . j a va2  s  .  c  om*/
        protected HBox call() throws Exception {

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

            ImageView imageRec = new ImageView(chatterAvatar.getImage()); //image
            imageRec.setFitHeight(60);
            imageRec.setFitWidth(50);

            String strChatterName = chat.getParticipant(); //add name of the chatter with light color
            strChatterName = Character.toUpperCase(strChatterName.charAt(0))
                    + strChatterName.substring(1, strChatterName.indexOf("@"));
            Label chatterName = new Label(strChatterName);
            chatterName.setDisable(true);

            Label timeL = new Label(time);
            timeL.setDisable(true);
            timeL.setFont(new Font("Arial", 10));

            //chat message
            BubbledLabel bbl = new BubbledLabel();
            bbl.setText(msg);
            bbl.setBackground(new Background(new BackgroundFill(Color.GAINSBORO, null, null)));

            vbox.getChildren().addAll(chatterName, bbl, timeL);
            vbox.setAlignment(Pos.CENTER_RIGHT);
            HBox hbox = new HBox();
            bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER);
            hbox.getChildren().addAll(imageRec, vbox);
            return hbox;
        }
    };

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

    });

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

From source file:ui.main.MainViewController.java

private synchronized void paintWarningInRecieve(Chat chat, String Warning, String time) {
    //this method draws the recievied text message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override/* w  w w  . j a  v  a  2s.  c o m*/
        protected HBox call() throws Exception {

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

            ImageView imageRec = new ImageView(chatterAvatar.getImage()); //image
            imageRec.setFitHeight(60);
            imageRec.setFitWidth(50);

            String strChatterName = chat.getParticipant(); //add name of the chatter with light color
            strChatterName = Character.toUpperCase(strChatterName.charAt(0))
                    + strChatterName.substring(1, strChatterName.indexOf("@"));
            Label chatterName = new Label(strChatterName);
            chatterName.setDisable(true);

            Label timeL = new Label(time);
            timeL.setDisable(true);
            timeL.setFont(new Font("Arial", 10));

            //chat message
            BubbledLabel bbl = new BubbledLabel();
            bbl.setText(Warning);
            bbl.setBackground(new Background(new BackgroundFill(Color.RED, null, null)));

            vbox.getChildren().addAll(chatterName, bbl, timeL);
            vbox.setAlignment(Pos.CENTER_RIGHT);
            HBox hbox = new HBox();
            bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER);
            hbox.getChildren().addAll(imageRec, vbox);
            return hbox;
        }
    };

    recievedMessages.setOnSucceeded(event -> {
        chatList.getChildren().add(recievedMessages.getValue());
        scrollPane.setVvalue(scrollPane.getHmax());
        scrollPane.setVvalue(scrollPane.getHmax());
    });

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

    }
}

From source file:ui.main.MainViewController.java

private synchronized void paintSendMessage(String msg, String time) {
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override/*from   w w  w .  j  av  a 2s . c  o  m*/
        protected HBox call() throws Exception {
            VBox vbox = new VBox(); //to add text

            ImageView imageRec = new ImageView(myAvatar.getImage());
            imageRec.setFitHeight(60);
            imageRec.setFitWidth(50);

            Label myName = new Label(name.getText());
            myName.setDisable(true);

            Label timeL = new Label(time);
            timeL.setDisable(true);
            timeL.setFont(new Font("Arial", 10));

            BubbledLabel bbl = new BubbledLabel();
            bbl.setText(msg);
            bbl.setBackground(new Background(new BackgroundFill(Color.LIGHTBLUE, null, null)));
            HBox hbox = new HBox();
            hbox.setAlignment(Pos.TOP_RIGHT);
            bbl.setBubbleSpec(BubbleSpec.FACE_RIGHT_CENTER);

            vbox.getChildren().addAll(myName, bbl, timeL);

            hbox.getChildren().addAll(vbox, imageRec);
            return hbox;
        }
    };

    recievedMessages.setOnSucceeded(event -> {
        chatList.getChildren().add(recievedMessages.getValue());
    });
    Thread t = new Thread(recievedMessages);
    t.setDaemon(true);
    t.start();
    try {
        t.join();
    } catch (InterruptedException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ui.main.MainViewController.java

private void paintConversationMessage(Message msg) {
    //this method draws the recievied text message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override/*from   www . j a  va 2  s  .  c  o  m*/
        protected HBox call() throws Exception {

            VBox vbox = new VBox(); //to add text
            String user = msg.getFrom();
            user = user.substring(user.indexOf("/") + 1, user.length());
            ImageView imageView = new ImageView(); //image
            imageView.setFitHeight(60);
            imageView.setFitWidth(50);
            VCard vcard = new VCard();
            try {
                vcard.load(ConnectionManager.getConnectionManager().getXMPPConnection(),
                        user.concat(AppData.serviceNameAt));
                if (vcard.getAvatar() != null) {
                    BufferedImage img = ImageIO.read(new ByteArrayInputStream(vcard.getAvatar()));
                    Image image = SwingFXUtils.toFXImage(img, null);
                    imageView.setImage(image);
                } else {
                    Image defaultAvatar = new Image("resources/defaultAvatar.png", 50, 60, true, true);
                    imageView.setImage(defaultAvatar);
                }
            } catch (XMPPException e) {
                Image defaultAvatar = new Image("resources/defaultAvatar.png", 50, 60, true, true);
                imageView.setImage(defaultAvatar);
                System.out.println(e);
            }

            Label chatterName = new Label(user);
            chatterName.setDisable(true);

            //chat message
            BubbledLabel bbl = new BubbledLabel();
            bbl.setText(msg.getBody());
            bbl.setBackground(new Background(new BackgroundFill(Color.GAINSBORO, null, null)));

            vbox.getChildren().addAll(chatterName, bbl);
            vbox.setAlignment(Pos.CENTER_RIGHT);
            HBox hbox = new HBox();
            bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER);
            hbox.getChildren().addAll(imageView, vbox);
            return hbox;
        }
    };

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

    });

    Thread t = new Thread(recievedMessages);
    //t.setDaemon(true);
    t.start();
    try {
        t.join();
    } catch (InterruptedException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
    Task t1 = new Task() {
        @Override
        protected Object call() throws Exception {
            Thread.sleep(500);
            return new Object();
        }
    };

    t1.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax()));

    Thread thread1 = new Thread(t1);
    thread1.start();
}