How to set -fx-max-width to USE_PREF_SIZE in JavaF

2019-02-23 08:10发布

问题:

Im writing a JavaFX-8 application and was wondering if it's possible to set min- or max-width of (e.g.) a Button to USE_PREF_SIZE by css. The class Region defines USE_PREF_SIZE as Double.NEGATIVE_INFINITY, but how to set negative Infinity in css? The JavaFX Reference Guide defines -fx-min-width, -fx-pref-width, -fx-max-width as <number> and a <number> is defined with the following regex [+|-]? [[0-9]+|[0-9]*"."[0-9]+] So maybe it is impossible?

I have tried (for fun) to assign the java way for negative infinity -1.0/0.0 and the css-parser has accepted the value, but without the expected effect. May someone could explain why it doesnt prints a warning or an error?

I already know how to set USE_PREF_SIZE by code and i also know the hack to set min, pref and max to the same value, but i want to do it in a css file the dynamic way.

Thanks in advance

回答1:

Looks like you can't actually do this at the moment... however the CSS parser does support Infinity...

Sounds like they're be pretty open to adding support for it if you open a new bug (that's how support for Infinity was added).