Reputation: 125
I have a javafx TextField
with an image in the text field to left. When the TextField
is focused the cursor appears right on the image, I want the cursor to appear next to image.
My css code:
#adminname {
-fx-background-color: white;
-fx-background-image: url("usericon.png");
-fx-background-repeat: no-repeat;
-fx-background-size: 20 20;
-fx-background-position: left center;
-fx-background-color: #a9a9a9 , white , white;
-fx-background-insets: 0 -1 -1 -1, 0 0 0 0, 0 -1 3 -1;
}
#adminname:focused {
-fx-background-color: white;
-fx-background-image: url("usericon.png");
-fx-background-repeat: no-repeat;
-fx-background-size: 25 25;
-fx-background-position: left center;
-fx-background-color: #a9a9a9 , white , white;
-fx-background-insets: 0 -1 -1 -1, 0 0 0 0, 0 -1 3 -1;
-fx-min-width: 170;
}
Upvotes: 0
Views: 698
Reputation: 82491
Use -fx-padding
(see CSS properties for Region
). Note however that the padding is not empty by default, so don't use 0 on the other values:
-fx-padding: 4 7 4 27;
The padding works the same way as in the standard css model. IMHO that description is better than the one in the javadoc for the Region
class. The important thing is the padding sets the distance to the border (i.e. the rounded rectangle around the TextField
) but isn't applied for the background.
Upvotes: 1