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
CSS styles are applied to nodes in the JavaFX scene graph in a way similar to the way CSS styles are applied to elements in the HTML DOM. Styles are first applied to the parent, then to its children.
I've found the easiest way to do this is to create an HBox and add the GridPane and the VBox to it. Set the "fillHeight" property to true on the HBox. The "fillWidth" properties on the GridPane and VBox should be set to true, and their HGrow properties set to "always," (or "sometimes").
Button SizeThe methods setMinWidth() and setMaxWidth() sets the minimum and maximum width the button should be allowed to have. The method setPrefWidth() sets the preferred width of the button. When there is space enough to display a button in its preferred width, JavaFX will do so.
Moreover, drag-and-drop can be implemented between a JavaFX application and a third-party (native) application such as Windows Explorer or a desktop. A drag-and-drop gesture happens as follows: The user click a mouse button on a gesture source, drags the mouse, and releases the mouse button on a gesture target.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With