Example usage for javafx.scene.control Label prefWidthProperty

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

Introduction

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

Prototype

public final DoubleProperty prefWidthProperty() 

Source Link

Usage

From source file:de.chaosfisch.uploader.gui.renderer.ProgressNodeRenderer.java

@Inject
public ProgressNodeRenderer(final Configuration configuration) {

    final Label progressInfo = LabelBuilder.create().build();
    progressInfo.textProperty().bind(progressBar.progressProperty().multiply(100).asString("%.2f%%"));

    progressInfo.setAlignment(Pos.CENTER_LEFT);
    progressInfo.prefWidthProperty().bind(progressBar.widthProperty().subtract(6));

    progressEta.alignmentProperty().set(Pos.CENTER_RIGHT);
    progressEta.prefWidthProperty().bind(progressBar.widthProperty().subtract(6));
    progressFinish.alignmentProperty().set(Pos.CENTER_RIGHT);
    progressFinish.prefWidthProperty().bind(progressBar.widthProperty().subtract(6));

    progressFinish.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false));
    progressBytes.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false));
    progressSpeed.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false));
    progressEta.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false));

    getChildren().addAll(progressBar, progressInfo, progressEta, progressSpeed, progressFinish, progressBytes);

    setOnMouseEntered(new EventHandler<MouseEvent>() {
        @Override/*www .  j  a  v  a  2s  .c  o m*/
        public void handle(final MouseEvent me) {
            progressFinish.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false));
            progressBytes.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false));
            progressSpeed.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false));
            progressEta.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false));
        }
    });

    setOnMouseExited(new EventHandler<MouseEvent>() {
        @Override
        public void handle(final MouseEvent me) {
            progressFinish.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false));
            progressBytes.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false));
            progressSpeed.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false));
            progressEta.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false));
        }
    });
}