From ac6129babfd2c14853850efcd6614a5ff7aeeddd Mon Sep 17 00:00:00 2001 From: Andrea Michelotti Date: Sat, 28 Nov 2026 15:18:30 +0100 Subject: [PATCH] Tabs widget: tab names invisible in the overflow menu until hovered The tab title was a Label 'graphic' next to a " " tab text, so that the font could be set. When not all tabs fit, the TabPane's overflow menu lists them with a copy of that graphic, which keeps the text but not the color set on the original, so the entries were drawn in the menu's default text color and were only readable on the hover highlight. Use the tab's own text for the title and set font and text color through the tab's style, which the tab label inherits. The overflow menu then shows regular, readable entries. --- .../javafx/widgets/TabsRepresentation.java | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/TabsRepresentation.java b/app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/TabsRepresentation.java index 9c35b35f3c..9f8ad27a22 100644 --- a/app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/TabsRepresentation.java +++ b/app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/TabsRepresentation.java @@ -55,9 +55,7 @@ public class TabsRepresentation extends JFXBaseRepresentation added) final String name = item.name().getValue(); final Pane content = new Pane(); - // 'Tab's are added with a Label as 'graphic' - // because that label allows setting the font. - - // Quirk: Tabs will not show the label unless there's also a non-empty text - final Tab tab = new Tab(" ", content); - final Label label = new Label(name); - tab.setGraphic(label); + // The title is the tab's own text, with font and color set via the tab's style + // (see updateChanges). It used to be a Label 'graphic' next to a " " text, but the + // menu listing the tabs that do not fit copies only the graphic's text, not its + // color, so those menu entries were invisible until hovered. + final Tab tab = new Tab(name, content); tab.setClosable(false); // !! tab.setUserData(item); @@ -286,17 +282,16 @@ public void updateChanges() if (dirty_layout.checkAndClear()) { - final String style = JFXUtil.shadedStyle(model_widget.propBackgroundColor().getValue()); + // Shading, plus the title font and color, which the tab's label inherits. + // -fx-text-base-color is the color modena.css uses for the tab label text. + final String style = JFXUtil.shadedStyle(model_widget.propBackgroundColor().getValue()) + + JFXUtil.cssFont("-fx-font", tab_font) + + "-fx-text-base-color: black;"; final Background background = new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), null, null)); for (Tab tab : jfx_node.getTabs()) - { // Set the font of the 'graphic' that's used to represent the tab - final Label label = (Label) tab.getGraphic(); - label.setFont(tab_font); - label.setTextFill(Color.BLACK); - - // Set colors + { // Set colors and font tab.setStyle(style); final Pane content = (Pane) tab.getContent();