javafx.scene.control.Label#setPrefHeight ( )源码实例Demo

下面列出了javafx.scene.control.Label#setPrefHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: constellation   文件: TimelinePanel.java
private Label createExtentLabel() {
    final Label newLabel = new Label();

    // Align the text vertically:
    newLabel.setRotate(270d);
    // Fix the dimensions to prevent jittery motion on value changes:
    newLabel.setMinWidth(150d);
    newLabel.setPrefWidth(150d);
    newLabel.setMaxWidth(150d);
    newLabel.setMinHeight(30d);
    newLabel.setPrefHeight(30d);
    newLabel.setMaxHeight(30d);
    newLabel.setAlignment(Pos.CENTER);

    return newLabel;
}
 
源代码2 项目: HubTurbo   文件: PickerAssignee.java
private Label getAssigneeLabel() {
    Label assigneeLoginName = new Label(getLoginName());
    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    double width = fontLoader.computeStringWidth(assigneeLoginName.getText(), assigneeLoginName.getFont());
    assigneeLoginName.setPrefWidth(width + 35);
    assigneeLoginName.setPrefHeight(LABEL_HEIGHT);
    assigneeLoginName.getStyleClass().add("labels");
    return assigneeLoginName;
}
 
源代码3 项目: HubTurbo   文件: PickerAssignee.java
private Label getAssigneeLabelWithAvatar() {
    Label assignee = new Label(getLoginName());
    assignee.setGraphic(getAvatarImageView());
    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    double width = fontLoader.computeStringWidth(assignee.getText(), assignee.getFont());
    assignee.setPrefWidth(width + 35 + AVATAR_SIZE);
    assignee.setPrefHeight(LABEL_HEIGHT);
    assignee.getStyleClass().add("labels");
    assignee.setStyle("-fx-background-color: lightgreen;");
    return assignee;
}
 
源代码4 项目: MusicPlayer   文件: ArtistsController.java
private VBox createCell(Artist artist) {

        VBox cell = new VBox();
        Label title = new Label(artist.getTitle());
        ImageView image = new ImageView(artist.getArtistImage());
        image.imageProperty().bind(artist.artistImageProperty());
        VBox imageBox = new VBox();

        title.setTextOverrun(OverrunStyle.CLIP);
        title.setWrapText(true);
        title.setPadding(new Insets(10, 0, 10, 0));
        title.setAlignment(Pos.TOP_LEFT);
        title.setPrefHeight(66);
        title.prefWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));

        image.fitWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));
        image.fitHeightProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));
        image.setPreserveRatio(true);
        image.setSmooth(true);

        imageBox.prefWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));
        imageBox.prefHeightProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));
        imageBox.setAlignment(Pos.CENTER);
        imageBox.getChildren().add(image);

        cell.getChildren().addAll(imageBox, title);
        cell.setPadding(new Insets(10, 10, 0, 10));
        cell.getStyleClass().add("artist-cell");
        cell.setAlignment(Pos.CENTER);
        cell.setOnMouseClicked(event -> {

            MainController mainController = MusicPlayer.getMainController();
            ArtistsMainController artistsMainController = (ArtistsMainController) mainController.loadView("ArtistsMain");

            VBox artistCell = (VBox) event.getSource();
            String artistTitle = ((Label) artistCell.getChildren().get(1)).getText();
            Artist a = Library.getArtist(artistTitle);
            artistsMainController.selectArtist(a);
        });
        
        cell.setOnDragDetected(event -> {
        	PseudoClass pressed = PseudoClass.getPseudoClass("pressed");
        	cell.pseudoClassStateChanged(pressed, false);
        	Dragboard db = cell.startDragAndDrop(TransferMode.ANY);
        	ClipboardContent content = new ClipboardContent();
            content.putString("Artist");
            db.setContent(content);
        	MusicPlayer.setDraggedItem(artist);
        	db.setDragView(cell.snapshot(null, null), cell.widthProperty().divide(2).get(), cell.heightProperty().divide(2).get());
            event.consume();
        });

        return cell;
    }