Java Code Examples for javafx.scene.control.Label#setBackground()
The following examples show how to use
javafx.scene.control.Label#setBackground() .
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: JaceUIController.java From jace with GNU General Public License v2.0 | 8 votes |
public void displayNotification(String message) { Label oldNotification = currentNotification; Label notification = new Label(message); currentNotification = notification; notification.setEffect(new DropShadow(2.0, Color.BLACK)); notification.setTextFill(Color.WHITE); notification.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 80, 0.7), new CornerRadii(5.0), new Insets(-5.0)))); Application.invokeLater(() -> { stackPane.getChildren().remove(oldNotification); stackPane.getChildren().add(notification); }); notificationExecutor.schedule(() -> { Application.invokeLater(() -> { stackPane.getChildren().remove(notification); }); }, 4, TimeUnit.SECONDS); }
Example 2
Source File: TextSymbolRepresentation.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@Override protected Label createJFXNode ( ) throws Exception { Label symbol = new Label(); symbol.setAlignment(JFXUtil.computePos(model_widget.propHorizontalAlignment().getValue(), model_widget.propVerticalAlignment().getValue())); symbol.setBackground(model_widget.propTransparent().getValue() ? null : new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), CornerRadii.EMPTY, Insets.EMPTY)) ); symbol.setFont(JFXUtil.convert(model_widget.propFont().getValue())); symbol.setTextFill(JFXUtil.convert(model_widget.propForegroundColor().getValue())); symbol.setText("\u263A"); enabled = model_widget.propEnabled().getValue(); Styles.update(symbol, Styles.NOT_ENABLED, !enabled); return symbol; }
Example 3
Source File: AlarmAreaView.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private void updateItem(final String item_name) { final Label view_item = itemViewMap.get(item_name); if (view_item == null) { logger.log(Level.WARNING, "Cannot update unknown alarm area item " + item_name); return; } final SeverityLevel severity = areaFilter.getSeverity(item_name); final Color color = AlarmUI.getColor(severity); view_item.setBackground(new Background(new BackgroundFill(color, radii, Insets.EMPTY))); if (color.getBrightness() >= 0.5) view_item.setTextFill(Color.BLACK); else view_item.setTextFill(Color.WHITE); }
Example 4
Source File: DirectionsPane.java From FXMaps with GNU Affero General Public License v3.0 | 6 votes |
/** * Adds a notification located at the top of the vertical pane, which * displays warning or other information about the current API state. * (i.e. if its in Beta etc.) * * @param message the message to display */ public void addDirectionsBulletinPane(String message) { Label l = new Label(message); l.setBackground(new Background( new BackgroundFill( Color.color( Color.YELLOW.getRed(), Color.YELLOW.getGreen(), Color.YELLOW.getBlue(), 0.4d), new CornerRadii(5), null))); l.setWrapText(true); l.setPrefWidth(200); l.setPadding(new Insets(5,5,5,5)); directionsBox.getChildren().add(l); }
Example 5
Source File: LineNumberFactory.java From RichTextFX with BSD 2-Clause "Simplified" License | 6 votes |
@Override public Node apply(int idx) { Val<String> formatted = nParagraphs.map(n -> format(idx+1, n)); Label lineNo = new Label(); lineNo.setFont(DEFAULT_FONT); lineNo.setBackground(DEFAULT_BACKGROUND); lineNo.setTextFill(DEFAULT_TEXT_FILL); lineNo.setPadding(DEFAULT_INSETS); lineNo.setAlignment(Pos.TOP_RIGHT); lineNo.getStyleClass().add("lineno"); // bind label's text to a Val that stops observing area's paragraphs // when lineNo is removed from scene lineNo.textProperty().bind(formatted.conditionOnShowing(lineNo)); return lineNo; }
Example 6
Source File: AlarmUI.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @return Label that indicates missing server connection */ public static Label createNoServerLabel() { final Label no_server = new Label("No Alarm Server Connection"); no_server.setTextFill(Color.WHITE); no_server.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY))); return no_server; }
Example 7
Source File: Viewer3d.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private Label createAxisLabel(final String text, final Color color) { final Label l = new Label(text); l.setPadding(LABEL_PADDING); l.setBackground(new Background(new BackgroundFill(color, new CornerRadii(5), null))); l.setTextFill(Color.WHITE); return l; }
Example 8
Source File: LabelTest.java From oim-fx with MIT License | 4 votes |
@Override public void start(Stage primaryStage) { try { Group root = new Group(); Scene scene = new Scene(root, 400, 400); Pane p = new Pane(); p.setPrefSize(400, 400); p.setBackground(new Background(new BackgroundFill(Color.GOLD, null, null))); root.getChildren().add(p); primaryStage.setScene(scene); primaryStage.setTitle("Conversation about Bubbles with Elltz"); primaryStage.show(); Label bl1 = new Label(); bl1.relocate(10, 50); bl1.setText("Hi Elltz -:)"); bl1.setBackground(new Background(new BackgroundFill(Color.YELLOWGREEN, null, null))); Label bl2 = new Label(); bl2.relocate(310, 100); bl2.setText("Heloooo Me"); bl2.setBackground(new Background(new BackgroundFill(Color.GREENYELLOW, null, null))); Label bl3 = new Label(); bl3.relocate(10, 150); bl3.setText("you know this would be a nice library"); bl3.setBackground(new Background(new BackgroundFill(Color.YELLOWGREEN, null, null))); Label bl4 = new Label(); bl4.relocate(165, 200); bl4.setText("uhmm yea, kinda, but yknow,im tryna \nact like im not impressed"); bl4.setBackground(new Background(new BackgroundFill(Color.GREENYELLOW, null, null))); Label bl5 = new Label(); bl5.relocate(10, 250); bl5.setText("yea! yea! i see that, lowkey.. you not gonna\n get upvotes though..lmao"); bl5.setBackground(new Background(new BackgroundFill(Color.YELLOWGREEN, null, null))); Label bl6 = new Label(); bl6.relocate(165, 300); bl6.setText("Man! shut up!!.. what you know about\n upvotes."); bl6.setBackground(new Background(new BackgroundFill(Color.GREENYELLOW, null, null))); p.getChildren().addAll(bl1, bl2, bl3, bl4, bl5, bl6); } catch (Exception e) { e.printStackTrace(); } }
Example 9
Source File: CalendarTileSkin.java From OEE-Designer with MIT License | 4 votes |
private void drawCells() { List<ChartData> dataList = tile.getChartData(); ZonedDateTime time = tile.getTime(); Locale locale = tile.getLocale(); int day = time.getDayOfMonth(); int startDay = time.withDayOfMonth(1).getDayOfWeek().getValue(); long lastDay = time.range(DAY_OF_MONTH).getMaximum(); Color textColor = tile.getTextColor(); Color bkgColor = tile.getBackgroundColor(); Font regFont = Fonts.latoRegular(size * 0.045); Font bldFont = Fonts.latoBold(size * 0.045); Background bkgToday = new Background(new BackgroundFill(tile.getBarColor(), new CornerRadii(size * 0.0125), new Insets(2))); Border appmntBorder = new Border(new BorderStroke(tile.getAlarmColor(), tile.getAlarmColor(), tile.getAlarmColor(), tile.getAlarmColor(), BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, new CornerRadii(size * 0.0125), BorderWidths.DEFAULT, new Insets(1))); boolean counting = false; int dayCounter = 1; for (int y = 0 ; y < 7 ; y++) { for (int x = 0 ; x < 8 ; x++) { int index = y * 8 + x; Label label = labels.get(index); String text; if (x == 0 && y == 0) { text = ""; label.setManaged(false); label.setVisible(false); } else if (y == 0) { text = DayOfWeek.of(x).getDisplayName(TextStyle.SHORT, locale); //label.setTextFill(x == 7 ? Tile.RED : textColor); label.setTextFill(textColor); label.setFont(bldFont); } else if (x == 0) { text = Integer.toString(time.withDayOfMonth(1).plusDays((y - 1) * 7).get(IsoFields.WEEK_OF_WEEK_BASED_YEAR)); label.setTextFill(Tile.GRAY); label.setFont(regFont); label.setBorder(weekBorder); } else { if (index - 7 > startDay) { counting = true; text = Integer.toString(dayCounter); LocalDate currentDay = time.toLocalDate().plusDays(dayCounter - 1); long appointments = dataList.stream().filter(data -> data.getTimestampAsLocalDate().isEqual(currentDay)).count(); if (x == 7) { if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setTextFill(Tile.RED); label.setFont(regFont); } else if (dayCounter == day) { if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setBackground(bkgToday); label.setTextFill(bkgColor); label.setFont(bldFont); } else { if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setTextFill(textColor); label.setFont(regFont); } } else { text = ""; label.setManaged(false); label.setVisible(false); } if (dayCounter > lastDay) { text = ""; label.setManaged(false); label.setVisible(false); } if (counting) { dayCounter++; } } label.setText(text); label.setVisible(true); label.setManaged(true); label.setPrefSize(cellWidth, cellHeight); label.relocate(x * cellWidth + cellOffsetX, y * cellHeight + cellOffsetY); } } }
Example 10
Source File: CalendarTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
private void drawCells() { List<ChartData> dataList = tile.getChartData(); ZonedDateTime time = tile.getTime(); Locale locale = tile.getLocale(); int day = time.getDayOfMonth(); int startDay = time.withDayOfMonth(1).getDayOfWeek().getValue(); long lastDay = time.range(DAY_OF_MONTH).getMaximum(); Color textColor = tile.getTextColor(); Color bkgColor = tile.getBackgroundColor(); Font regFont = Fonts.latoRegular(size * 0.045); Font bldFont = Fonts.latoBold(size * 0.045); Background bkgToday = new Background(new BackgroundFill(tile.getBarColor(), new CornerRadii(size * 0.0125), new Insets(2))); Border appmntBorder = new Border(new BorderStroke(tile.getAlarmColor(), tile.getAlarmColor(), tile.getAlarmColor(), tile.getAlarmColor(), BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, new CornerRadii(size * 0.0125), BorderWidths.DEFAULT, new Insets(1))); boolean counting = false; int dayCounter = 1; for (int y = 0 ; y < 7 ; y++) { for (int x = 0 ; x < 8 ; x++) { int index = y * 8 + x; Label label = labels.get(index); String text; if (x == 0 && y == 0) { text = ""; label.setManaged(false); label.setVisible(false); } else if (y == 0) { text = DayOfWeek.of(x).getDisplayName(TextStyle.SHORT, locale); //label.setTextFill(x == 7 ? Tile.RED : textColor); label.setTextFill(textColor); label.setFont(bldFont); } else if (x == 0) { text = Integer.toString(time.withDayOfMonth(1).plusDays((y - 1) * 7).get(IsoFields.WEEK_OF_WEEK_BASED_YEAR)); label.setTextFill(Tile.GRAY); label.setFont(regFont); label.setBorder(weekBorder); } else { if (index - 7 > startDay) { counting = true; text = Integer.toString(dayCounter); LocalDate currentDay = time.toLocalDate().plusDays(dayCounter - 1); long appointments = dataList.stream().filter(data -> data.getTimestampAsLocalDate().isEqual(currentDay)).count(); if (x == 7) { if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setTextFill(Tile.RED); label.setFont(regFont); } else if (dayCounter == day) { if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setBackground(bkgToday); label.setTextFill(bkgColor); label.setFont(bldFont); } else { int currentDayCounter = dayCounter; if (dataList.stream().filter(data -> data.getTimestampAsLocalDate().getDayOfMonth() == currentDayCounter).count() > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setTextFill(textColor); label.setFont(regFont); } } else { text = ""; label.setManaged(false); label.setVisible(false); } if (dayCounter > lastDay) { text = ""; label.setManaged(false); label.setVisible(false); } if (counting) { dayCounter++; } } label.setText(text); label.setVisible(true); label.setManaged(true); label.setPrefSize(cellWidth, cellHeight); label.relocate(x * cellWidth + cellOffsetX, y * cellHeight + cellOffsetY); } } }
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; }