Java Code Examples for javafx.scene.control.Label#setTextOverrun()
The following examples show how to use
javafx.scene.control.Label#setTextOverrun() .
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: AutoCompleteItem.java From BlockMap with MIT License | 6 votes |
public AutoCompleteItem() { name = new Label(); name.setAlignment(Pos.CENTER_LEFT); name.setStyle("-fx-font-weight: bold;"); path = new Label(); path.setMaxWidth(Double.POSITIVE_INFINITY); HBox.setHgrow(path, Priority.ALWAYS); HBox.setMargin(path, new Insets(0, 8, 0, 0)); path.setAlignment(Pos.CENTER_RIGHT); path.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); graphic = new ImageView(); graphic.setPreserveRatio(true); graphic.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> name.getFont().getSize() * 1.2, name.fontProperty())); setText(null); setGraphic(new HBox(2, graphic, name, path)); setPrefWidth(0); }
Example 2
Source File: DateTileSkin.java From OEE-Designer with MIT License | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); final ZonedDateTime TIME = tile.getTime(); titleText = new Text(DAY_FORMATTER.format(TIME)); titleText.setFill(tile.getTitleColor()); description = new Label(Integer.toString(TIME.getDayOfMonth())); description.setAlignment(Pos.CENTER); description.setTextAlignment(TextAlignment.CENTER); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.72); description.setFont(Fonts.latoLight(PREFERRED_HEIGHT * 0.65)); text = new Text(MONTH_YEAR_FORMATTER.format(TIME)); text.setFill(tile.getTextColor()); getPane().getChildren().addAll(titleText, text, description); }
Example 3
Source File: TextTileSkin.java From OEE-Designer with MIT License | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); description.setTextAlignment(TextAlignment.RIGHT); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getDescriptionColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, text, description); }
Example 4
Source File: CharacterTileSkin.java From OEE-Designer with MIT License | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(Pos.CENTER); description.setTextAlignment(TextAlignment.CENTER); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, text, description); }
Example 5
Source File: DateTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); final ZonedDateTime TIME = tile.getTime(); titleText = new Text(DAY_FORMATTER.format(TIME)); titleText.setFill(tile.getTitleColor()); description = new Label(Integer.toString(TIME.getDayOfMonth())); description.setAlignment(Pos.CENTER); description.setTextAlignment(TextAlignment.CENTER); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.72); description.setFont(Fonts.latoLight(PREFERRED_HEIGHT * 0.65)); text = new Text(MONTH_YEAR_FORMATTER.format(TIME)); text.setFill(tile.getTextColor()); getPane().getChildren().addAll(titleText, text, description); }
Example 6
Source File: TextTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); description.setTextAlignment(TextAlignment.RIGHT); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, text, description); }
Example 7
Source File: CharacterTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(Pos.CENTER); description.setTextAlignment(TextAlignment.CENTER); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, text, description); }
Example 8
Source File: MediaListCell.java From dolphin-platform with Apache License 2.0 | 5 votes |
public MediaListCell() { getStyleClass().add("media-list-cell"); title = new SimpleStringProperty(); description = new SimpleStringProperty(); textSpacing = CssHelper.createProperty(StyleableProperties.TEXT_SPACING, this); showDescription = CssHelper.createProperty(StyleableProperties.SHOW_DESCRIPTION, this); centerBox = new VBox(); centerBox.spacingProperty().bind(textSpacing); titleLabel = new Label(); titleLabel.getStyleClass().add("media-cell-title"); titleLabel.textProperty().bind(title); VBox.setVgrow(titleLabel, Priority.NEVER); descriptionLabel = new Label(); //TODO: CSS descriptionLabel.setWrapText(true); descriptionLabel.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); descriptionLabel.getStyleClass().add("media-cell-description"); descriptionLabel.textProperty().bind(description); VBox.setVgrow(titleLabel, Priority.ALWAYS); centerBox.getChildren().addAll(titleLabel, descriptionLabel); setCenterContent(centerBox); showDescription.addListener(e -> { descriptionLabel.setManaged(isShowDescription()); descriptionLabel.setVisible(isShowDescription()); }); }
Example 9
Source File: StatusTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); description.setTextAlignment(TextAlignment.RIGHT); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); Color foregroundColor = getSkinnable().getForegroundColor(); Color halfTranslucent = Helper.getColorWithOpacity(foregroundColor, 0.5); verticalDivider = new Line(0, PREFERRED_HEIGHT * 0.35, PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.35); verticalDivider.getStrokeDashArray().addAll(2.0, 2.0); verticalDivider.setStrokeDashOffset(1); verticalDivider.setStroke(halfTranslucent); verticalDivider.setStrokeWidth(1); horizontal1Divider = new Line(PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85); horizontal1Divider.getStrokeDashArray().addAll(2.0, 2.0); horizontal1Divider.setStrokeDashOffset(1); horizontal1Divider.setStroke(halfTranslucent); horizontal1Divider.setStrokeWidth(1); horizontal2Divider = new Line(2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, 2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85); horizontal2Divider.getStrokeDashArray().addAll(2.0, 2.0); horizontal2Divider.setStrokeDashOffset(1); horizontal2Divider.setStroke(halfTranslucent); horizontal2Divider.setStrokeWidth(1); leftGraphicsPane = new StackPane(); middleGraphicsPane = new StackPane(); rightGraphicsPane = new StackPane(); if (null != tile.getLeftGraphics()) { leftGraphicsPane.getChildren().setAll(tile.getLeftGraphics()); } if (null != tile.getMiddleGraphics()) { middleGraphicsPane.getChildren().setAll(tile.getMiddleGraphics()); } if (null != tile.getRightGraphics()) { rightGraphicsPane.getChildren().setAll(tile.getRightGraphics()); } leftValueLabel = new Label(); leftValueLabel.setAlignment(Pos.CENTER); middleValueLabel = new Label(); middleValueLabel.setAlignment(Pos.CENTER); rightValueLabel = new Label(); rightValueLabel.setAlignment(Pos.CENTER); leftLabel = new Label(); leftLabel.setAlignment(Pos.CENTER); middleLabel = new Label(); middleLabel.setAlignment(Pos.CENTER); rightLabel = new Label(); rightLabel.setAlignment(Pos.CENTER); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, description, verticalDivider, horizontal1Divider, horizontal2Divider, leftGraphicsPane, middleGraphicsPane, rightGraphicsPane, leftValueLabel, middleValueLabel, rightValueLabel, leftLabel, middleLabel, rightLabel, text); }
Example 10
Source File: MessageItem.java From helloiot with GNU General Public License v3.0 | 4 votes |
public MessageItem(EventMessage message) { getStyleClass().add("message"); setMaxSize(Double.MAX_VALUE, 60.0); setMinSize(Control.USE_COMPUTED_SIZE, 60.0); setPrefSize(Control.USE_COMPUTED_SIZE, 60.0); HBox.setHgrow(this, Priority.SOMETIMES); StringFormat format = StringFormatIdentity.INSTANCE; String txt = format.format(format.value(message.getMessage())); Label messageview = new Label(txt); messageview.setTextOverrun(OverrunStyle.ELLIPSIS); messageview.getStyleClass().add("unitinputview"); BorderPane.setAlignment(messageview, Pos.CENTER_LEFT); setCenter(messageview); HBox footer = new HBox(); Label topictext = new Label(message.getTopic()); topictext.setTextOverrun(OverrunStyle.ELLIPSIS); topictext.getStyleClass().add("messagefooter"); topictext.setMaxWidth(Double.MAX_VALUE); HBox.setHgrow(topictext, Priority.ALWAYS); footer.getChildren().add(topictext); DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); Label datetext = new Label(LocalDateTime.now().format(dtf)); datetext.getStyleClass().add("messagefooter"); footer.getChildren().add(datetext); MiniVar v2 = message.getProperty("mqtt.retained"); if (v2 != null && v2.asBoolean()) { Label retainedtext = new Label(resources.getString("badge.retained")); retainedtext.getStyleClass().addAll("badge", "badgeretained"); footer.getChildren().add(retainedtext); } MiniVar v = message.getProperty("mqtt.qos"); if (v != null) { Label qostext = new Label(String.format(resources.getString("badge.qos"), v.asInt())); qostext.getStyleClass().addAll("badge", "badgeqos"); footer.getChildren().add(qostext); } setBottom(footer); }
Example 11
Source File: FX.java From FxDock with Apache License 2.0 | 4 votes |
/** creates a label. accepts: CssStyle, CssID, FxCtl, Insets, OverrunStyle, Pos, TextAlignment, Color, Node, Background */ public static Label label(Object ... attrs) { Label n = new Label(); for(Object a: attrs) { if(a == null) { // ignore } else if(a instanceof CssStyle) { n.getStyleClass().add(((CssStyle)a).getName()); } else if(a instanceof CssID) { n.setId(((CssID)a).getID()); } else if(a instanceof FxCtl) { switch((FxCtl)a) { case BOLD: n.getStyleClass().add(CssTools.BOLD.getName()); break; case FOCUSABLE: n.setFocusTraversable(true); break; case FORCE_MAX_WIDTH: n.setMaxWidth(Double.MAX_VALUE); break; case FORCE_MIN_HEIGHT: n.setMinHeight(Control.USE_PREF_SIZE); break; case FORCE_MIN_WIDTH: n.setMinWidth(Control.USE_PREF_SIZE); break; case NON_FOCUSABLE: n.setFocusTraversable(false); break; case WRAP_TEXT: n.setWrapText(true); break; default: throw new Error("?" + a); } } else if(a instanceof Insets) { n.setPadding((Insets)a); } else if(a instanceof OverrunStyle) { n.setTextOverrun((OverrunStyle)a); } else if(a instanceof Pos) { n.setAlignment((Pos)a); } else if(a instanceof String) { n.setText((String)a); } else if(a instanceof TextAlignment) { n.setTextAlignment((TextAlignment)a); } else if(a instanceof Color) { n.setTextFill((Color)a); } else if(a instanceof StringProperty) { n.textProperty().bind((StringProperty)a); } else if(a instanceof Node) { n.setGraphic((Node)a); } else if(a instanceof Background) { n.setBackground((Background)a); } else { throw new Error("?" + a); } } return n; }
Example 12
Source File: ArtistsController.java From MusicPlayer with MIT License | 4 votes |
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; }
Example 13
Source File: ControlPanelTableCell.java From MusicPlayer with MIT License | 4 votes |
@Override protected void updateItem(T item, boolean empty) { super.updateItem(item, empty); Song song = (Song) this.getTableRow().getItem(); if (empty || item == null || song == null) { setText(null); setGraphic(null); } else if (!song.getSelected()) { setText(item.toString()); setGraphic(null); song.selectedProperty().removeListener(listener); song.selectedProperty().addListener(listener); } else { String fileName; // Selects the correct control panel based on whether the user is in a play list or not. if (MusicPlayer.getMainController().getSubViewController() instanceof PlaylistsController) { fileName = Resources.FXML + "ControlPanelPlaylists.fxml"; } else { fileName = Resources.FXML + "ControlPanel.fxml"; } try { Label text = new Label(item.toString()); text.setTextOverrun(OverrunStyle.CLIP); FXMLLoader loader = new FXMLLoader(this.getClass().getResource(fileName)); HBox controlPanel = loader.load(); BorderPane cell = new BorderPane(); cell.setRight(controlPanel); cell.setCenter(text); BorderPane.setAlignment(text, Pos.CENTER_LEFT); BorderPane.setAlignment(controlPanel, Pos.CENTER_LEFT); setText(null); setGraphic(cell); song.selectedProperty().removeListener(listener); song.selectedProperty().addListener(listener); } catch (Exception ex) { ex.printStackTrace(); } } }