Example usage for javafx.scene.control Label fontProperty

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

Introduction

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

Prototype

public final ObjectProperty<Font> fontProperty() 

Source Link

Document

The default font to use for text in the Labeled.

Usage

From source file:pah9qdmoviereviews.MovieReviewsFXMLController.java

public void ready(Stage stage, Scene scene) {
    this.stage = stage;
    this.scene = scene;

    movieReviewManager = new NYTMoviewReviewManager();
    movieReviewManager.addPropertyChangeSupport(((evt) -> {
        switch (evt.getPropertyName()) {
        case "Exception":
            Platform.runLater(() -> displayExceptionAlert((Exception) evt.getNewValue()));
            break;
        case "Add Movie Review":
            Platform.runLater(() -> {
                movieReviews.add((NYTMovieReview) evt.getNewValue());
                this.foundText.setText(("Found " + movieReviews.size() + " results for " + searchString + "."));
            });/* ww w. j av  a2  s.c  o m*/
            break;
        case "Clear Movie Reviews":
            Platform.runLater(() -> movieReviews.clear());
            break;
        case "Completed":
            if (movieReviews.isEmpty())
                this.foundText.setText("No reviews found for " + searchString);
            break;
        default:
            Platform.runLater(
                    () -> displayExceptionAlert(new Exception("Invalid Property Change Support Property")));
            break;
        }

    }));

    movieReviews = FXCollections.observableArrayList();
    listView.setItems(movieReviews);
    listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<NYTMovieReview>() {
        @Override
        public void changed(ObservableValue<? extends NYTMovieReview> observable, NYTMovieReview oldValue,
                NYTMovieReview newValue) {
            detailsBox.getChildren().clear();
            movieImage.setImage(null);
            if (newValue != null) {
                DateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
                String pictureLink = newValue.getPictureLink();
                if (pictureLink != null && !pictureLink.isEmpty()) {
                    reviewBox.getChildren().remove(0);
                    reviewBox.getChildren().add(0, movieImage);
                    movieImage.setImage(new Image(pictureLink));
                } else {
                    reviewBox.getChildren().remove(0);
                    reviewBox.getChildren().add(0, missingImageText);
                    movieImage.setImage(null);
                }

                ArrayList<Label> labelArray = new ArrayList<>();
                if (!newValue.getDisplayTitle().isEmpty()) {
                    Label titleLabel = new Label(newValue.getDisplayTitle());
                    titleLabel.fontProperty().set(Font.font(20));
                    labelArray.add(titleLabel);
                }
                if (!newValue.getSummary().isEmpty()) {
                    labelArray.add(new Label("Summary: " + newValue.getSummary()));
                }
                if (!newValue.getMpaaRating().isEmpty()) {
                    labelArray.add(new Label("MPAA Rating: " + newValue.getMpaaRating()));
                }
                if (newValue.getPublicationDate() != null) {
                    labelArray.add(
                            new Label("Publication Date: " + dateFormat.format(newValue.getPublicationDate())));
                }
                if (newValue.getOpeningDate() != null) {
                    labelArray.add(new Label("Opening Date: " + dateFormat.format(newValue.getOpeningDate())));
                }

                labelArray.forEach((label) -> {
                    label.wrapTextProperty().set(true);
                });

                detailsBox.getChildren().addAll(labelArray);

                Button openButton = new Button("Open Review");
                openButton.setOnAction((event) -> {
                    try {
                        Desktop.getDesktop().browse(new URI(newValue.getArticleLink()));
                    } catch (Exception ex) {
                        displayExceptionAlert(ex);
                    }
                });

                detailsBox.getChildren().add(openButton);
            }
        }
    });

    HBox.setMargin(missingImageText, new Insets(15, 15, 15, 15));
    searchTextField.setOnKeyPressed((event) -> {
        if (event.getCode() == KeyCode.ENTER) {
            loadReviews(searchTextField.getText());
        }
    });
    //        searchTextField.textProperty().addListener((observable, oldValue, newValue) -> {
    //            if(newValue != null && !newValue.isEmpty())
    //                loadReviews(newValue);
    //        });
}