JavaFX: How to determine margin in TextField in css?
Is it possible to specify padding and margin for TextField
in JavaFX using CSS? I've tried -fx-padding
some other properties too, but no effect. I am using JavaFX 2.2 which is included with the latest Java 7.
I have a lot of text boxes and something like:
<GridPane.margin>
<Insets bottom="10.0" left="60.0" right="0.0" top="10.0"/>
</GridPane.margin>
after every textbox doesn't work for me.
source to share
Modified copy from Set field for individual element via java fx css
Theres no -fx-margin: 5px css property for javafx textboxes, but you can get around this behavior with a combination of padding, border insertion, and background nesting.
For example, a text box with a 5px margin.
.text-field-with-margin {
-fx-padding: 5px;
-fx-border-insets: 5px;
-fx-background-insets: 5px;
}
Alternatively, you can also define higher padding and bottom padding values if you want padding and margins.
source to share
TextField
JavaFX has a CSS class text-field
.
You can define the following rule:
.text-field { .... }
But I think you want to create some spacing around the margins, right? Unfortunately TextField
there is no margin property for s.
I usually define padding to wrap Control
. In this case, you define padding for all GridPanes.
Check out the JavaFX CSS link for more information .
source to share