I also agree that this is a good idea. 
As of now, we can only change the theme by reacting to the Platform Preferences (listener) and change the Stylesheet of the Scene(s).
I'm not sure how well this works as I never tried it as of now (Might even be problematic for Tooltips, Dialogs and Dialogs without an owner). 
 
So media queries are the better and correct solution for this problem.
I use them myself for light/dark theme in the Web and they work pretty good, are easy to set up and read. So following this standard is the right choice.
 
Media queries are normally often used with 'width' and 'height' as well, e.g.
@media (width <= 1250px) {
  /* … */
}
I wonder if we want to support that as well.
Since JavaFX follows the 'container' approach, where the container (Pane) is responsible for the layout, this does not seem to be that useful or needed in JavaFX (compared to the Web).
Although I can think of some usecases like changing (decrease/increase) the padding or the alignment of some Controls when a specific width or height is reached.
 
Are there any plans to include this at a later date? If not, perhaps we should document this.
Other opinions on this topic are also welcome.

In any case, starting with the preferences is the right decision and IMO will bring the most benefit.
 
-- Marius
 
Gesendet: Montag, 2. Dezember 2024 um 17:22
Von: "Michael Strauß" <michaelstr...@gmail.com>
An: openjfx-dev <openjfx-dev@openjdk.org>
Betreff: CSS Media Queries
Hi everyone,

here's a proposal to add media queries to JavaFX, which is a powerful
feature to adjust stylesheets to changes in the runtime environment.

Proposal: https://gist.github.com/mstr2/cbb93bff03e073ec0c32aac317b22de7
PR: https://github.com/openjdk/jfx/pull/1655


Reply via email to