Example usage for javafx.scene.control Label Label

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

Introduction

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

Prototype

public Label() 

Source Link

Document

Creates an empty label

Usage

From source file:com.panemu.tiwulfx.form.BaseControl.java

private PopupControl getPopup() {
    if (popup == null) {
        errorLabel = new Label();
        errorLabel.textProperty().bind(getErrorMessage());
        popup = new PopupControl();
        final HBox pnl = new HBox();
        pnl.getChildren().add(errorLabel);
        pnl.getStyleClass().add("error-popup");
        popup.setSkin(new Skin() {
            @Override//from   w  w  w  . java  2s  .c  om
            public Skinnable getSkinnable() {
                return BaseControl.this.getInputComponent();
            }

            @Override
            public Node getNode() {
                return pnl;
            }

            @Override
            public void dispose() {
            }
        });
        popup.setHideOnEscape(true);
    }
    return popup;
}

From source file:com.panemu.tiwulfx.form.BaseListControl.java

private PopupControl getPopup() {
    if (popup == null) {
        errorLabel = new Label();
        errorLabel.textProperty().bind(getErrorMessage());
        popup = new PopupControl();
        final HBox pnl = new HBox();
        pnl.getChildren().add(errorLabel);
        pnl.getStyleClass().add("error-popup");
        popup.setSkin(new Skin() {
            @Override//from   w  w  w . ja v  a2  s . c  o  m
            public Skinnable getSkinnable() {
                return null;//BaseTableFormControl.this.getInputComponent();
            }

            @Override
            public Node getNode() {
                return pnl;
            }

            @Override
            public void dispose() {
            }
        });
        popup.setHideOnEscape(true);
    }
    return popup;
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

private void autoComplete(int slashPosition, String input, ContextMenu autoCompletePopup) {

    XPathSuggestions xPathSuggestions = new XPathSuggestions(parent.getLanguageVersion().getLanguage());
    List<String> suggestions = xPathSuggestions.getXPathSuggestions(input.trim());

    List<CustomMenuItem> resultToDisplay = new ArrayList<>();
    if (!suggestions.isEmpty()) {

        for (int i = 0; i < suggestions.size() && i < 5; i++) {
            final String searchResult = suggestions.get(i);

            Label entryLabel = new Label();
            entryLabel.setGraphic(highlightXPathSuggestion(suggestions.get(i), input));
            entryLabel.setPrefHeight(5);
            CustomMenuItem item = new CustomMenuItem(entryLabel, true);
            resultToDisplay.add(item);//from  w w w  . j  a v a2 s .  c o m

            item.setOnAction(e -> {
                xpathExpressionArea.replaceText(slashPosition, slashPosition + input.length(), searchResult);
                autoCompletePopup.hide();
            });
        }
    }
    autoCompletePopup.getItems().setAll(resultToDisplay);

    xpathExpressionArea.getCharacterBoundsOnScreen(slashPosition, slashPosition + input.length()).ifPresent(
            bounds -> autoCompletePopup.show(xpathExpressionArea, bounds.getMinX(), bounds.getMaxY()));
}

From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.OrganizerImpl.java

private void initializeFilesTree() {
    folderTree.setOnMouseClicked(event -> handleFolderChange());
    folderTree.setCellFactory(treeView -> {
        HBox hbox = new HBox();
        hbox.setMaxWidth(200);/*from  ww  w.  j a v  a2  s.  c  o m*/
        hbox.setPrefWidth(200);
        hbox.setSpacing(7);

        FontAwesomeIconView openFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_OPEN_ALT);
        openFolderIcon.setTranslateY(7);
        FontAwesomeIconView closedFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_ALT);
        closedFolderIcon.setTranslateY(7);

        Label dirName = new Label();
        dirName.setMaxWidth(150);

        FontAwesomeIconView removeIcon = new FontAwesomeIconView(FontAwesomeIcon.REMOVE);

        Tooltip deleteToolTip = new Tooltip();
        deleteToolTip.setText("Verzeichnis aus Workspace entfernen");

        Button button = new Button(null, removeIcon);
        button.setTooltip(deleteToolTip);
        button.setTranslateX(8);

        return new TreeCell<String>() {
            @Override
            public void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
                if (item == null || empty) {
                    setGraphic(null);
                    setText(null);
                } else if (getTreeItem() instanceof FilePathTreeItem) {
                    hbox.getChildren().clear();
                    dirName.setText(item);
                    if (getTreeItem().isExpanded()) {
                        hbox.getChildren().add(openFolderIcon);
                    } else {
                        hbox.getChildren().add(closedFolderIcon);
                    }
                    hbox.getChildren().add(dirName);
                    TreeItem<String> treeItem = getTreeItem();
                    TreeItem<String> parent = treeItem != null ? treeItem.getParent() : null;
                    if (parent != null && parent.equals(folderTree.getRoot())) {
                        String path = ((FilePathTreeItem) getTreeItem()).getFullPath();
                        button.setOnAction(event -> handleDeleteDirectory(Paths.get(path)));
                        hbox.getChildren().add(button);
                    }
                    setGraphic(hbox);
                }
            }
        };
    });
}

From source file:qupath.lib.gui.panels.classify.RandomTrainingRegionSelector.java

private void createDialog() {
    dialog = new Stage();
    dialog.initOwner(qupath.getStage());
    dialog.setTitle("Training sample selector");

    pointCreator = new RandomPointCreator();

    for (PathClass pathClass : pathClassListModel) {
        if (pathClass != null && pathClass.getName() != null)
            pointCreator.addPathClass(pathClass,
                    KeyCode.getKeyCode(pathClass.getName().toUpperCase().substring(0, 1)));
        //            pointCreator.addPathClass(pathClass, KeyStroke.getKeyStroke(new pathClass.getName().toLowerCase().charAt(0), 0).getKeyCode());
    }/*from ww  w.  j  av a  2  s  .c  o  m*/
    //      PathClass tumourClass = PathClassFactory.getDefaultPathClass(PathClasses.TUMOR);
    //      PathClass stromaClass = PathClassFactory.getDefaultPathClass(PathClasses.STROMA);
    //      pointCreator.addPathClass(tumourClass, KeyCode.T);
    //      pointCreator.addPathClass(stromaClass, KeyCode.S);
    QuPathViewer viewer = qupath.getViewer();
    pointCreator.registerViewer(viewer);

    // Adapt to changing active viewers
    ImageDataChangeListener<BufferedImage> listener = new ImageDataChangeListener<BufferedImage>() {

        @Override
        public void imageDataChanged(ImageDataWrapper<BufferedImage> source,
                ImageData<BufferedImage> imageDataOld, ImageData<BufferedImage> imageDataNew) {
            if (pointCreator != null) {
                QuPathViewer viewer = qupath.getViewer();
                pointCreator.registerViewer(viewer);
                updateObjectCache(viewer);
            }
            refreshList();
            updateLabel();
        }

    };
    qupath.addImageDataChangeListener(listener);

    // Remove listeners for cleanup
    dialog.setOnCloseRequest(e -> {
        pointCreator.deregisterViewer();
        qupath.removeImageDataChangeListener(listener);
        dialog.setOnCloseRequest(null);
        dialog = null;
        // Re-enable mode switching
        qupath.setModeSwitchingEnabled(true);
    });

    ParameterPanelFX paramPanel = new ParameterPanelFX(params);
    paramPanel.getPane().setPadding(new Insets(2, 5, 5, 5));

    list = new ListView<PathClass>(pathClassListModel);
    list.setPrefSize(400, 200);

    // TODO: ADD A SENSIBLE RENDERER!
    // For now, this is simply duplicated from PathAnnotationPanel
    list.setCellFactory(new Callback<ListView<PathClass>, ListCell<PathClass>>() {

        @Override
        public ListCell<PathClass> call(ListView<PathClass> p) {

            ListCell<PathClass> cell = new ListCell<PathClass>() {

                @Override
                protected void updateItem(PathClass value, boolean bln) {
                    super.updateItem(value, bln);
                    int size = 10;
                    if (value == null) {
                        setText(null);
                        setGraphic(null);
                    } else if (value.getName() == null) {
                        setText("None");
                        setGraphic(new Rectangle(size, size, ColorToolsFX.getCachedColor(0, 0, 0, 0)));
                    } else {
                        setText(value.getName());
                        setGraphic(new Rectangle(size, size, ColorToolsFX.getPathClassColor(value)));
                    }
                }

            };

            return cell;
        }
    });

    //      list.setCellRenderer(new PathClassListCellRendererPoints());

    list.setTooltip(new Tooltip("Available classes"));

    labelCount = new Label();
    labelCount.setTextAlignment(TextAlignment.CENTER);
    labelCount.setPadding(new Insets(5, 0, 5, 0));
    BorderPane panelTop = new BorderPane();
    panelTop.setTop(paramPanel.getPane());
    panelTop.setCenter(list);
    panelTop.setBottom(labelCount);
    labelCount.prefWidthProperty().bind(panelTop.widthProperty());
    updateLabel();

    //      panelButtons.add(new JButton(new UndoAction("Undo")));
    Action actionAdd = new Action("Add to class", e -> {
        if (list == null || pointCreator == null)
            return;
        PathClass pathClass = list.getSelectionModel().getSelectedItem();
        pointCreator.addPoint(pathClass);
    });
    Action actionSkip = new Action("Skip", e -> {
        if (pointCreator != null)
            pointCreator.addPoint(null);
    });

    GridPane panelButtons = PanelToolsFX.createColumnGridControls(ActionUtils.createButton(actionAdd),
            ActionUtils.createButton(actionSkip));

    BorderPane pane = new BorderPane();
    pane.setCenter(panelTop);
    pane.setBottom(panelButtons);

    pane.setPadding(new Insets(10, 10, 10, 10));
    Scene scene = new Scene(pane);
    dialog.setScene(scene);
}

From source file:editeurpanovisu.EquiCubeDialogController.java

/**
 *
 *//*from w w w. j a v a  2  s.  co m*/
private void validerE2C() {
    if (fileLstFichier == null) {
        Alert alert = new Alert(AlertType.ERROR);
        alert.setTitle(rbLocalisation.getString("transformation.traiteImages"));
        alert.setHeaderText(null);
        alert.setContentText(rbLocalisation.getString("transformation.traiteImagesPasFichiers"));
        alert.showAndWait();
    } else {
        Alert alert = new Alert(AlertType.WARNING);
        alert.setTitle(rbLocalisation.getString("transformation.traiteImages"));
        alert.setHeaderText(null);
        alert.setContentText(rbLocalisation.getString("transformation.traiteImagesMessage"));
        alert.showAndWait();

        lblTermine = new Label();
        lblTermine.setText("Traitement en cours");
        lblTermine.setLayoutX(24);
        lblTermine.setLayoutY(250);
        paneChoixTypeFichier.getChildren().add(lblTermine);
        pbBarreAvancement.setId("bar");
        lblTermine.setId("lblTermine");
        pbBarreAvancement.setVisible(true);
        pbBarreImage.setVisible(true);
        Task taskTraitement;
        taskTraitement = tskTraitement();
        pbBarreAvancement.progressProperty().unbind();
        pbBarreImage.setProgress(0.001);
        pbBarreAvancement.setProgress(0.001);
        pbBarreAvancement.progressProperty().bind(taskTraitement.progressProperty());
        lblTermine.textProperty().unbind();
        lblTermine.textProperty().bind(taskTraitement.messageProperty());
        Thread thrTraitement = new Thread(taskTraitement);
        thrTraitement.setDaemon(true);
        thrTraitement.start();
    }
}

From source file:com.panemu.tiwulfx.table.TableControl.java

private void initControls() {
    this.getStyleClass().add("table-control");
    btnAdd = buildButton(TiwulFXUtil.getGraphicFactory().createAddGraphic());
    btnDelete = buildButton(TiwulFXUtil.getGraphicFactory().createDeleteGraphic());
    btnEdit = buildButton(TiwulFXUtil.getGraphicFactory().createEditGraphic());
    btnExport = buildButton(TiwulFXUtil.getGraphicFactory().createExportGraphic());
    btnReload = buildButton(TiwulFXUtil.getGraphicFactory().createReloadGraphic());
    btnSave = buildButton(TiwulFXUtil.getGraphicFactory().createSaveGraphic());

    btnFirstPage = new Button();
    btnFirstPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageFirstGraphic());
    btnFirstPage.setOnAction(paginationHandler);
    btnFirstPage.setDisable(true);/*from  w  w w. j  a va  2s .  c  om*/
    btnFirstPage.setFocusTraversable(false);
    btnFirstPage.getStyleClass().addAll("pill-button", "pill-button-left");

    btnPrevPage = new Button();
    btnPrevPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPagePrevGraphic());
    btnPrevPage.setOnAction(paginationHandler);
    btnPrevPage.setDisable(true);
    btnPrevPage.setFocusTraversable(false);
    btnPrevPage.getStyleClass().addAll("pill-button", "pill-button-center");

    btnNextPage = new Button();
    btnNextPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageNextGraphic());
    btnNextPage.setOnAction(paginationHandler);
    btnNextPage.setDisable(true);
    btnNextPage.setFocusTraversable(false);
    btnNextPage.getStyleClass().addAll("pill-button", "pill-button-center");

    btnLastPage = new Button();
    btnLastPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageLastGraphic());
    btnLastPage.setOnAction(paginationHandler);
    btnLastPage.setDisable(true);
    btnLastPage.setFocusTraversable(false);
    btnLastPage.getStyleClass().addAll("pill-button", "pill-button-right");

    cmbPage = new ComboBox<>();
    cmbPage.setEditable(true);
    cmbPage.setOnAction(paginationHandler);
    cmbPage.setFocusTraversable(false);
    cmbPage.setDisable(true);
    cmbPage.getStyleClass().addAll("combo-page");
    cmbPage.setPrefWidth(75);

    paginationBox = new HBox();
    paginationBox.setAlignment(Pos.CENTER);
    paginationBox.getChildren().addAll(btnFirstPage, btnPrevPage, cmbPage, btnNextPage, btnLastPage);

    spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    toolbar = new ToolBar(btnReload, btnAdd, btnEdit, btnSave, btnDelete, btnExport, spacer, paginationBox);
    toolbar.getStyleClass().add("table-toolbar");

    footer = new StackPane();
    footer.getStyleClass().add("table-footer");
    lblRowIndex = new Label();
    lblTotalRow = new Label();
    menuButton = new TableControlMenu(this);
    StackPane.setAlignment(lblRowIndex, Pos.CENTER_LEFT);
    StackPane.setAlignment(lblTotalRow, Pos.CENTER);
    StackPane.setAlignment(menuButton, Pos.CENTER_RIGHT);

    lblTotalRow.visibleProperty().bind(progressIndicator.visibleProperty().not());

    progressIndicator.setProgress(-1);
    progressIndicator.visibleProperty().bind(service.runningProperty());
    toolbar.disableProperty().bind(service.runningProperty());
    menuButton.disableProperty().bind(service.runningProperty());

    footer.getChildren().addAll(lblRowIndex, lblTotalRow, menuButton, progressIndicator);
    VBox.setVgrow(tblView, Priority.ALWAYS);
    getChildren().addAll(toolbar, tblView, footer);

}

From source file:io.bitsquare.app.BitsquareApp.java

private void showFPSWindow() {
    Label label = new Label();
    EventStreams.animationTicks().latestN(100).map(ticks -> {
        int n = ticks.size() - 1;
        return n * 1_000_000_000.0 / (ticks.get(n) - ticks.get(0));
    }).map(d -> String.format("FPS: %.3f", d)).feedTo(label.textProperty());

    Pane root = new StackPane();
    root.getChildren().add(label);//from   w w  w . j  av a  2 s  . c  o m
    Stage stage = new Stage();
    stage.setScene(new Scene(root));
    stage.setTitle("FPS");
    stage.initModality(Modality.NONE);
    stage.initStyle(StageStyle.UTILITY);
    stage.initOwner(scene.getWindow());
    stage.setX(primaryStage.getX() + primaryStage.getWidth() + 10);
    stage.setY(primaryStage.getY());
    stage.setWidth(200);
    stage.setHeight(100);
    stage.show();
}

From source file:edu.kit.trufflehog.view.jung.visualization.FXVisualizationViewer.java

synchronized private void initVertex(INode vertex) {

    if (vertex.getAddress().isMulticast()) {
        return;/*from w ww  .j  a  v  a2 s .  c  o m*/
    }

    final IRenderer renderer = vertex.getComponent(ViewComponent.class).getRenderer();
    final Shape nodeShape = renderer.getShape();
    //nodeShape.addEventFilter( MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler());
    //nodeShape.addEventFilter( MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler());

    //nodeShape.setCache(false);
    //nodeShape.setCacheHint(CacheHint.);

    final NodeStatisticsComponent nsc = vertex.getComponent(NodeStatisticsComponent.class);

    final DoubleBinding nodeSize = MyBindings
            .divideIntToDouble(nsc.getCommunicationCountProperty(), port.getMaxThroughputProperty()).add(1);

    nodeShape.scaleXProperty().bind(nodeSize);
    nodeShape.scaleYProperty().bind(nodeSize);

    nodeShape.setLayoutX(layout.transform(vertex).getX());
    nodeShape.setLayoutY(layout.transform(vertex).getY());

    ///////////
    // LABEL //
    ///////////

    Label nodeLabel = new Label();

    // cast the shapes to circles (because right now i know they are circles) //TODO make this for arbitrary shapes
    final Circle nodeCircle = (Circle) nodeShape;

    /*        final DoubleProperty labelX = new SimpleDoubleProperty();
            final DoubleProperty labelY = new SimpleDoubleProperty();*/

    //labelX.bind(nodeShape.layoutXProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty())));
    //labelY.bind(nodeShape.layoutYProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty())));

    //nodeLabel.layoutXProperty().bindBidirectionalWithOffset(labelX);
    //nodeLabel.layoutYProperty().bindBidirectionalWithOffset(labelY);

    //nodeLabel.layoutXProperty().bind(nodeShape.layoutXProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty())));

    nodeLabel.textFillProperty().bind(new SimpleObjectProperty<>(Color.WHITE));

    //MyBindings.bindBidirectionalWithOffset(nodeLabel.layoutXProperty(), nodeShape.layoutXProperty(), nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty()));
    //MyBindings.bindBidirectionalWithOffset(nodeLabel.layoutYProperty(), nodeShape.layoutYProperty(), nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty()));

    nodeLabel.layoutXProperty().bind(nodeShape.layoutXProperty().add(nodeShape.translateXProperty())
            .add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty())));
    nodeLabel.layoutYProperty().bind(nodeShape.layoutYProperty().add(nodeShape.translateYProperty())
            .add(nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty())));

    NodeInfoComponent nic = vertex.getComponent(NodeInfoComponent.class);
    if (nic != null) {
        nodeLabel.textProperty().bind(nic.toStringBinding());
    }

    nodeLabel.scaleXProperty().bind(Bindings.divide(1, canvas.scaleXProperty()));
    nodeLabel.scaleYProperty().bind(Bindings.divide(1, canvas.scaleYProperty()));

    nodeLabel.addEventFilter(MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler(vertex));
    nodeLabel.addEventFilter(MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler(vertex));
    nodeLabel.addEventFilter(MouseEvent.MOUSE_RELEASED, nodeGestures.getOnMouseReleasedEventHandler(vertex));

    nodeShape.addEventFilter(MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler(vertex));
    nodeShape.addEventFilter(MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler(vertex));
    nodeShape.addEventFilter(MouseEvent.MOUSE_RELEASED, nodeGestures.getOnMouseReleasedEventHandler(vertex));
    nodeShape.addEventFilter(MouseEvent.MOUSE_CLICKED, nodeGestures.getOnMouseClickedEventHandler(vertex));

    canvas.getChildren().addAll(nodeLabel, nodeShape);
}

From source file:mesclasses.view.JourneeController.java

/**
 * dessine la grid vie scolaire//ww  w  . j  av a2  s.  c o m
 * @param eleve
 * @param rowIndex 
 */
private void drawVieScolaire(Eleve eleve, int rowIndex) {
    EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve);
    drawEleveName(vieScolaireGrid, eleve, rowIndex);
    if (!eleve.isInClasse(currentDate.getValue())) {
        return;
    }
    CheckBox box = new CheckBox();
    Bindings.bindBidirectional(box.selectedProperty(), eleveData.absentProperty());
    vieScolaireGrid.add(box, 3, rowIndex, null);

    TextField retardField = new TextField();
    retardField.setMaxWidth(50);
    Bindings.bindBidirectional(retardField.textProperty(), eleveData.retardProperty(),
            new IntegerOnlyConverter());
    markAsInteger(retardField);

    vieScolaireGrid.add(retardField, 4, rowIndex, HPos.CENTER);

    Label cumulRetard = new Label();
    retardField.textProperty().addListener((observable, oldValue, newValue) -> {
        writeAndMarkInRed(cumulRetard, stats.getNbRetardsUntil(eleve, currentDate.getValue()), 3);
    });

    writeAndMarkInRed(cumulRetard, stats.getNbRetardsUntil(eleve, currentDate.getValue()), 3);
    vieScolaireGrid.add(cumulRetard, 5, rowIndex, null);
}