On Sat, 7 Jun 2025 00:35:02 GMT, Cormac Redmond <d...@openjdk.org> wrote:
> It appears that the CSS of the Window icons cannot be overridden; see below > example which doesn't apply css.css. > > What is the proper/expected way to style the window icons; and should there > be some documentation on this somewhere in HeaderBar? The default buttons can't be styled, because their appearance is an unspecified implementation detail of the platform toolkit. These are the reasons for this decision: 1. Not all platform toolkits use CSS-styled buttons in the first place; macOS uses the system-provided buttons instead. So this would only work on some platforms. 2. Specifying these kinds of internals would increase the specification surface of this feature. All future improvements would be weighed down by compatibility constraints, because we wouldn't be able to change the implementation in a way that breaks existing applications (w.r.t. the internal structure of the buttons, style classes, and so on). If you need to customize the window buttons, the proper way is as follows: 1. Remove the default header buttons by setting their preferred height to 0, using the `HeaderBar.setPrefButtonHeight(Stage, double)` method. 2. Create your own buttons (just regular JavaFX buttons), place them in the header bar, and style them as you like. 3. Use `HeaderBar.setButtonType(Node, HeaderButtonType)` to tell JavaFX the semantic type of your buttons. This is important to enable window manager integrations with the native platform. ------------- PR Comment: https://git.openjdk.org/jfx/pull/1605#issuecomment-2951354902