How to set -fx-max-width to USE_PREF_SIZE in JavaFX css?

淺唱寂寞╮ 提交于 2019-12-19 19:46:15

问题


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).



来源:https://stackoverflow.com/questions/26940341/how-to-set-fx-max-width-to-use-pref-size-in-javafx-css

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!