On Fri, 2 May 2025 10:32:42 GMT, Michael Strauß <mstra...@openjdk.org> wrote:

>> Implementation of 
>> [`StageStyle.EXTENDED`](https://gist.github.com/mstr2/0befc541ee7297b6db2865cc5e4dbd09).
>
> Michael Strauß has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   simplify header area picking

I was testing the HeaderBar, and noticed the styles of the windows buttons were 
sometimes not applied, or were getting stuck in a particular state (i.e., hover 
state). I thought I tracked this down to a benign issue where my app was 
applying duplicate stylesheets, in quick succession (i.e., twice) -- it should 
not matter usually, at all, but for some reason affected the window decoration 
icons in particular.

I fixed that edge-case issue. However, I then quickly noticed the styling will 
stop being applied after using a common controlsfx notification popup. It can 
be very easily reproduced:


package com.certak.kafkio.gui;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HeaderBar;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.controlsfx.control.Notifications;

import java.time.LocalDateTime;

public class WindowDecorationsStylesGoMissing extends Application {

    @Override
    public void start(Stage primaryStage) {
        primaryStage.initStyle(StageStyle.EXTENDED);
        BorderPane borderPane = new BorderPane();
        borderPane.setTop(new HeaderBar());

        Button click = new Button("Click");
        click.setOnAction(event -> {
            notify("Clicked at: " + LocalDateTime.now(), primaryStage);
        });
        borderPane.setCenter(click);

        Scene scene = new Scene(borderPane, 400, 300);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public void notify(String message, Stage mainWindow) {
        Notifications.create()
                .text(message)
                .owner(mainWindow)
                .show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}


Run this, click the button and hover over the window icons, and see that no 
styling is applied anymore. I have not dived into this yet to understand _why_, 
but I know from memory that controlsfx does some re-arranging of nodes in scene 
usually.

Either way, the styling of HeaderBar seems quite unreliable/brittle given the 
various ways it can seemingly break. I don't know why, or what makes it 
different. But the other styles in my app appear unaffected by application bugs 
and/or quirks of controlsfx.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1605#issuecomment-2848834102

Reply via email to