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(String text, Node graphic) 

Source Link

Document

Creates a Label with the supplied text and graphic.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);/*  ww w .j  a v a  2 s . c om*/
    stage.setHeight(180);

    HBox hbox = new HBox();
    Image image = new Image(getClass().getResourceAsStream("labels.jpg"));
    Label label1 = new Label("Search", new ImageView(image));

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);//from  ww  w .  j a  v a  2 s .  c  om
    stage.setHeight(180);

    HBox hbox = new HBox();
    Image image = new Image(getClass().getResourceAsStream("labels.jpg"));
    Label label1 = new Label("Search", new ImageView(image));

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    label1.setLabelFor(hbox);
    System.out.println(label1.labelForProperty());
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);/* w  w  w  .ja  va  2 s  . c  om*/
    stage.setHeight(180);

    HBox hbox = new HBox();
    Image image = new Image(getClass().getResourceAsStream("labels.jpg"));
    Label label1 = new Label("Search", new ImageView(image));

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    label1.setLabelFor(hbox);
    System.out.println(label1.getLabelFor());
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);/*from ww w  .j  a v  a2  s  .com*/
    stage.setHeight(180);

    HBox hbox = new HBox();
    Image image = new Image(getClass().getResourceAsStream("labels.jpg"));
    Label label1 = new Label("Search", new ImageView(image));

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    label1.setLabelFor(hbox);

    stage.setScene(scene);
    stage.show();
}

From source file:org.pdfsam.ui.news.News.java

News(NewsData data) {
    this.getStyleClass().add("news-box");
    TextFlow flow = new TextFlow();
    if (data.isImportant()) {
        Text megaphone = GlyphsDude.createIcon(FontAwesomeIcon.BULLHORN, "1.2em");
        megaphone.getStyleClass().clear();
        megaphone.getStyleClass().add("news-box-title-important");
        flow.getChildren().addAll(megaphone, new Text(" "));
    }//from   w w w .j  av a  2s  .c  o m

    Text titleText = new Text(data.getTitle() + System.lineSeparator());
    titleText.setOnMouseClicked(e -> eventStudio().broadcast(new OpenUrlRequest(data.getLink())));
    titleText.getStyleClass().add("news-box-title");

    Text contentText = new Text(data.getContent());
    contentText.setTextAlignment(TextAlignment.JUSTIFY);
    contentText.getStyleClass().add("news-content");

    flow.getChildren().addAll(titleText, contentText);
    flow.setTextAlignment(TextAlignment.JUSTIFY);
    Label labelDate = new Label(FORMATTER.format(data.getDate()),
            GlyphsDude.createIcon(MaterialDesignIcon.CLOCK));
    labelDate.setPrefWidth(Integer.MAX_VALUE);
    HBox.setHgrow(labelDate, Priority.ALWAYS);
    HBox bottom = new HBox(labelDate);
    bottom.setAlignment(Pos.CENTER_LEFT);
    bottom.getStyleClass().add("news-box-footer");
    if (isNotBlank(data.getLink())) {
        Button link = UrlButton.urlButton(null, data.getLink(), FontAwesomeIcon.EXTERNAL_LINK_SQUARE,
                "pdfsam-toolbar-button");
        bottom.getChildren().add(link);
    }
    getChildren().addAll(flow, bottom);
}

From source file:ch.tuason.djbattlescore.lib.components.comps.ResultGridPane.java

/**
 * adds a certain DjEntity to the ranking grid panel...
 * //from w  w  w  .j  a  v  a2 s . c  om
 * @param results a Collection of DjEntity...
 */
public void addCurrentDJRanking(Collection<DjEntity> results) {
    this.addedRankingComponents.clear();
    this.currentDjRanking = results;
    if (this.currentDjRanking != null && !this.currentDjRanking.isEmpty()) {
        int iPos = 1;
        for (DjEntity dj : this.currentDjRanking) {

            Image djImage = null;

            if (!StringUtils.isEmpty(dj.getAvatarPicPath32())) {
                djImage = getImageFromCache(dj);

                if (djImage == null) {
                    try {
                        djImage = new Image(getClass().getResourceAsStream(
                                DjBattleConstants.IMAGE_RESOURCE_BASE_FOR_DJ_PICS + dj.getAvatarPicPath32()));
                        if (!djImage.isError()) {
                            imageCache.put(dj.getId(), djImage);
                        }
                    } catch (Exception e) {
                        System.out.println("the image for dj '" + dj.getName()
                                + "' could not be loaded for the avatar image... " + e.getMessage());
                        djImage = null;
                    }
                }

                // it might be an absolute path?
                if (djImage == null) {
                    try {
                        djImage = new Image(
                                DjBattleConstants.ABSOLUTE_IMAGE_FILEPATH_PREFIX + dj.getAvatarPicPath32());
                        if (!djImage.isError()) {
                            imageCache.put(dj.getId(), djImage);
                        }
                    } catch (Exception e) {
                        System.out.println("the image for dj '" + dj.getName()
                                + "' could not be loaded for the avatar image... " + e.getMessage());
                        djImage = null;
                    }
                }

                if (djImage == null) {
                    djImage = getStandardImage();
                }
            }

            if (StringUtils.isEmpty(dj.getAvatarPicPath32()) || djImage == null) {
                djImage = getStandardImage();
            }

            HBox djComponent = new HBox();
            djComponent.setPadding(new Insets(5, 0, 0, 20));

            Label djLabel = new Label(dj.getDjNameWithSoundStyle(), new ImageView(djImage));
            djLabel.setFont(new Font("Arial", 20));
            // component.setTextFill(Color.web(DjBattleConstants.COLOR_RESULT_TITLE_TEXT));
            djComponent.getChildren().add(djLabel);

            this.addedRankingComponents.add(djComponent);
            this.add(djComponent, 0, iPos);
            iPos++;
        }
    }
}

From source file:ch.tuason.djbattlescore.lib.components.comps.NowPlayingImageRotator.java

private Label getNowPlayingTitleLabel() {

    if (titleLabel == null) {
        Image image = new Image(
                getClass().getResourceAsStream(DjBattleConstants.IMAGE_RESOURCE_TURNTABLE_LOGO_48));
        titleLabel = new Label("Spinning the Decks", new ImageView(image));
        titleLabel.setFont(new Font("Arial", 30));
        titleLabel.setTextFill(Color.web(DjBattleConstants.COLOR_RESULT_TITLE_TEXT));
    }/*from   ww  w .ja va  2  s.c om*/
    return titleLabel;
}

From source file:ch.tuason.djbattlescore.lib.components.comps.ResultGridPane.java

private Label getResultTitleLabel() {
    if (resultTitleLabel == null) {
        Image image = new Image(
                getClass().getResourceAsStream(DjBattleConstants.IMAGE_RESOURCE_TURNTABLE_LOGO_48));
        resultTitleLabel = new Label("Current Ranking", new ImageView(image));
        resultTitleLabel.setFont(new Font("Arial", 30));
        resultTitleLabel.setTextFill(Color.web(DjBattleConstants.COLOR_RESULT_TITLE_TEXT));
    }/*from   ww w.  j a va  2 s  . c  o m*/
    return resultTitleLabel;
}