Java Code Examples for javafx.scene.control.Label#setPrefWidth()

The following examples show how to use javafx.scene.control.Label#setPrefWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewsPanel.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public NewsPanel() {
    getStyleClass().add("news-panel");
    getStyleClass().addAll(Style.CONTAINER.css());
    Button closeButton = FontAwesomeIconFactory.get().createIconButton(FontAwesomeIcon.TIMES);
    closeButton.getStyleClass().addAll("close-button");
    closeButton.setOnAction(e -> eventStudio().broadcast(HideNewsPanelRequest.INSTANCE));
    Label titleLabel = new Label(DefaultI18nContext.getInstance().i18n("What's new"));
    titleLabel.setPrefWidth(Integer.MAX_VALUE);
    titleLabel.getStyleClass().add("news-panel-title");

    StackPane top = new StackPane(titleLabel, closeButton);
    top.setAlignment(Pos.TOP_RIGHT);

    scroll.getStyleClass().add("scrollable-news");
    scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    scroll.setFitToHeight(true);
    scroll.setFitToWidth(true);
    getChildren().addAll(top, scroll);

    eventStudio().addAnnotatedListeners(this);
}
 
Example 2
Source File: PickerLabel.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Node getNode() {
    // actual name for labels at the top, add tick for selected labels
    Label label = new Label((canDisplayFullName ? getFullName() : getShortName()));
    setLabelStyle(label);
    label.setText(label.getText() + (!canDisplayFullName && isSelected ? " ✓" : ""));

    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    double width = fontLoader.computeStringWidth(label.getText(), label.getFont());
    label.setPrefWidth(width + 30);

    if (isInGroup()) {
        Tooltip groupTooltip = new Tooltip(getGroupName());
        label.setTooltip(groupTooltip);
    }

    setupEvents(label);
    return label;
}
 
Example 3
Source File: PollenDashboard.java    From medusademo with Apache License 2.0 6 votes vote down vote up
private HBox getHBox(final String TEXT, final Gauge GAUGE) {
    Label label = new Label(TEXT);
    label.setPrefWidth(150);
    label.setFont(Font.font(26));
    label.setTextFill(MaterialDesign.GREY_800.get());
    label.setAlignment(Pos.CENTER_LEFT);
    label.setPadding(new Insets(0, 10, 0, 0));

    GAUGE.setBarBackgroundColor(Color.rgb(232, 231, 223));
    GAUGE.setAnimated(true);
    GAUGE.setAnimationDuration(1000);

    HBox hBox = new HBox(label, GAUGE);
    hBox.setSpacing(20);
    hBox.setAlignment(Pos.CENTER_LEFT);
    return hBox;
}
 
Example 4
Source File: News.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
News(NewsData data) {
    this.getStyleClass().add("news-box");
    TextFlow flow = new TextFlow();
    if (data.isImportant()) {
        Text megaphone = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.BULLHORN, "1.2em");
        megaphone.getStyleClass().clear();
        megaphone.getStyleClass().add("news-box-title-important");
        flow.getChildren().addAll(megaphone, new Text(" "));
    }

    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()),
            MaterialDesignIconFactory.get().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);
}
 
Example 5
Source File: PreferencesStage.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
public VBox getHeadings()
{
  HBox hbox = new HBox();
  hbox.setSpacing(5.0D);
  hbox.setPadding(new Insets(10.0D, 5.0D, 0.0D, 5.0D));
  
  for (int i = 0; i < this.fields.size(); i++)
  {
    PreferenceField field = (PreferenceField)this.fields.get(i);
    Label heading = new Label(field.heading);
    hbox.getChildren().add(heading);
    heading.setPrefWidth(field.width);
    if (field.type == Type.BOOLEAN) {
      heading.setAlignment(Pos.CENTER);
    }
  }
  VBox vbox = new VBox();
  vbox.setSpacing(5.0D);
  vbox.setPadding(new Insets(0.0D, 15.0D, 0.0D, 15.0D));
  vbox.getChildren().add(hbox);
  
  return vbox;
}
 
Example 6
Source File: PickerMilestone.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
private HBox createMilestoneDetailsBox() {
    HBox milestoneDetailsBox = new HBox();
    milestoneDetailsBox.setSpacing(3);
    milestoneDetailsBox.setPrefWidth(250);
    milestoneDetailsBox.setAlignment(Pos.CENTER_RIGHT);

    if (getDueDate().isPresent()) {
        Label dueDate = new Label(getDueDate().get().toString());
        dueDate.setPrefWidth(150);
        milestoneDetailsBox.getChildren().add(dueDate);
    }

    MilestoneProgressBar progressBar = new MilestoneProgressBar(getProgress());
    Label progressLabel = new Label(String.format("%3.0f%%", getProgress() * 100));
    progressLabel.setPrefWidth(50);
    milestoneDetailsBox.getChildren().addAll(progressBar, progressLabel);
    return milestoneDetailsBox;
}
 
Example 7
Source File: TransfersTab.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private HBox getLine (Label label, HBox hbox)
{
  HBox line = new HBox (10);

  line.getChildren ().addAll (label, hbox);
  label.setPrefWidth (LABEL_WIDTH);

  return line;
}
 
Example 8
Source File: TransfersTab.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private HBox getLine (Label label, TextField text, HBox hbox)
{
  HBox line = new HBox (10);

  line.getChildren ().addAll (label, text, hbox);
  label.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (100);
  text.setFont (defaultFont);
  text.setEditable (true);
  text.setFocusTraversable (true);

  return line;
}
 
Example 9
Source File: TransfersTab.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private HBox getLine (Label label, TextField text)
{
  HBox line = new HBox (10);
  line.getChildren ().addAll (label, text);
  label.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (100);
  text.setFont (defaultFont);
  text.setEditable (true);
  text.setFocusTraversable (true);

  return line;
}
 
Example 10
Source File: TakeOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private Label createPopoverLabel(String text) {
    final Label label = new Label(text);
    label.setPrefWidth(300);
    label.setWrapText(true);
    label.setPadding(new Insets(10));
    return label;
}
 
Example 11
Source File: TransfersTab.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
private HBox getLine (Label label, HBox hbox)
{
  HBox line = new HBox (10);

  line.getChildren ().addAll (label, hbox);
  label.setPrefWidth (LABEL_WIDTH);

  return line;
}
 
Example 12
Source File: TakeOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private Tuple2<Label, VBox> getTradeInputBox(HBox amountValueBox, String promptText) {
    Label descriptionLabel = new AutoTooltipLabel(promptText);
    descriptionLabel.setId("input-description-label");
    descriptionLabel.setPrefWidth(170);

    VBox box = new VBox();
    box.setPadding(new Insets(10, 0, 0, 0));
    box.setSpacing(2);
    box.getChildren().addAll(descriptionLabel, amountValueBox);
    return new Tuple2<>(descriptionLabel, box);
}
 
Example 13
Source File: MetaPanel.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static void formatLabels(final Label... labels)
{
	for (Label label : labels) {
		label.setAlignment(Pos.BASELINE_CENTER);
		label.setPrefWidth(TEXTFIELD_WIDTH);
	}
}
 
Example 14
Source File: Pin.java    From BlockMap with MIT License 5 votes vote down vote up
protected PopOver initInfo() {
	PopOver info = new PopOver();
	info.setArrowLocation(ArrowLocation.BOTTOM_CENTER);
	info.setAutoHide(true);
	info.setHeaderAlwaysVisible(true);
	/* Workaround: If the PopOver it too thin, it will be placed a bit off. Bug report: https://github.com/controlsfx/controlsfx/issues/1095 */
	Label content = new Label();
	content.setPrefWidth(130);
	info.setContentNode(content);
	info.setTitle(type.name);
	return info;
}
 
Example 15
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private Label createPopoverLabel(String text) {
    final Label label = new Label(text);
    label.setPrefWidth(300);
    label.setWrapText(true);
    label.setPadding(new Insets(10));
    return label;
}
 
Example 16
Source File: MobileNotificationsView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private Label createMarketAlertPriceInfoPopupLabel(String text) {
    final Label label = new Label(text);
    label.setPrefWidth(300);
    label.setWrapText(true);
    label.setPadding(new Insets(10));
    return label;
}
 
Example 17
Source File: PickerAssignee.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 18
Source File: AboutDialog.java    From archivo with GNU General Public License v3.0 4 votes vote down vote up
private void addWrappedLabel(String text, Pane pane) {
    Label label = new Label(text);
    label.setPrefWidth(DIALOG_WIDTH);
    label.setWrapText(true);
    pane.getChildren().add(label);
}
 
Example 19
Source File: IccProfileEditorController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
private void makeTagsInputs() {
    try {
        tagDataBox.getChildren().clear();
        if (tags == null) {
            return;
        }
        isSettingValues = true;
        for (IccTag tag : tags.getTags()) {
            if (tag.getType() == null) {
                continue;
            }

            HBox tagBox = new HBox();
            tagBox.setAlignment(Pos.CENTER_LEFT);
            tagBox.setMaxSize(Double.MAX_VALUE, Region.USE_COMPUTED_SIZE);
            tagBox.setSpacing(5);
            VBox.setVgrow(tagBox, Priority.NEVER);
            HBox.setHgrow(tagBox, Priority.ALWAYS);

            Label label = new Label(message(tag.getName()));
            label.setPrefWidth(Region.USE_COMPUTED_SIZE);
            label.wrapTextProperty().setValue(true);
            tagBox.getChildren().add(label);

            switch (tag.getType()) {
                case Text:
                case MultiLocalizedUnicode:
                case Signature:
                case DateTime:
                    makeTagTextInput(tagBox, tag);
                    break;

                case XYZ:
                    makeTagXYZNumberInput(tagBox, tag);
                    break;

                case Curve:
                    makeTagCurveInput(tagBox, tag);
                    break;

                case ViewingConditions:
                    makeTagViewingConditionsInput(tagBox, tag);
                    break;

                case Measurement:
                    makeTagMeasurementInput(tagBox, tag);
                    break;

                case S15Fixed16Array:
                    makeTagS15Fixed16ArrayInput(tagBox, tag);
                    break;

                case LUT: {
                    Label label2 = new Label(message("NotSupportEditCurrently"));
                    label.setPrefWidth(Region.USE_COMPUTED_SIZE);
                    label.wrapTextProperty().setValue(true);
                    tagBox.getChildren().add(label2);
                }
                break;

                default:
                    break;

            }

            tagDataBox.getChildren().add(tagBox);
        }
        FxmlControl.refreshStyle(tagDataBox);
        isSettingValues = false;
    } catch (Exception e) {
        logger.debug(e.toString());

    }
}
 
Example 20
Source File: ZoomerSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    final FlowPane root = new FlowPane();
    root.setAlignment(Pos.CENTER);

    DataSet testDataSet = generateData();

    Label label = new Label("left-click-hold-drag for zooming. middle-button for panning.\n"
                            + "Tip: drag horizontally/vertically/diagonally for testing; try to select the outlier");
    label.setFont(Font.font(20));
    label.setAlignment(Pos.CENTER);
    label.setContentDisplay(ContentDisplay.CENTER);
    label.setPrefWidth(2.0 * PREF_WIDTH);

    // chart with default zoom
    final Chart chart1 = getTestChart("default zoom", testDataSet);
    Zoomer zoomer1 = new Zoomer();
    registerZoomerChangeListener(zoomer1, chart1.getTitle());
    chart1.getPlugins().add(zoomer1);

    // chart with auto xy zoom
    final Chart chart2 = getTestChart("auto xy zoom", testDataSet);
    final Zoomer zoomer2 = new Zoomer();
    zoomer2.setAutoZoomEnabled(true);
    registerZoomerChangeListener(zoomer2, chart2.getTitle());
    chart2.getPlugins().add(zoomer2);

    // chart with x-only zoom
    final Chart chart3 = getTestChart("x-only zoom", testDataSet);
    Zoomer zoomer3 = new Zoomer(AxisMode.X);
    registerZoomerChangeListener(zoomer3, chart3.getTitle());
    chart3.getPlugins().add(zoomer3);

    // chart with x-only zoom
    final Chart chart4 = getTestChart("y-only zoom", testDataSet);
    Zoomer zoomer4 = new Zoomer(AxisMode.Y);
    registerZoomerChangeListener(zoomer4, chart4.getTitle());
    chart4.getPlugins().add(zoomer4);

    root.getChildren().addAll(chart1, chart2, chart3, chart4, label);

    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(new Scene(root));
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
    primaryStage.show();
}