Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set only a top padding in JavaFX [duplicate]

I want to specify only one (or several) values for a padding using CSS in JavaFX.

I've read the documentation here http://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#typesize but I can either specify a value for all four side of padding, or a value for each one.

Is it not possible to specify, for example, my top padding and let the rest be inherited? Same goes for borders..

like image 768
Maxoudela Avatar asked May 26 '15 12:05

Maxoudela


2 Answers

You will have to CSS like so yourObject.setStyle("-fx-padding: 10 0 0 0;"); This will add padding only on the top side of your object. In CSS, the padding parameters are entered in this order: TOP, RIGHT, BOTTOM, LEFT. Clockwise. So ie. if you wanted to add 30 padding to the left side of your object, you'd use this: yourObject.setStyle("-fx-padding: 0 0 0 30;"); You can also combine it anyway you want (top and right for example).

like image 153
Mirza Suljić Avatar answered Nov 17 '22 05:11

Mirza Suljić


you can edit it easly with sceneBuilder

enter image description here

so if you want to edit the padding with your code java (in particular when you make an interanl class ) you can simply call the function setPadding(), ok!. But if you want to set the margin you have to do that throught the parent layout because it's not internal properties .. ==> [your element_parent_layout].setMargin([your element], new Insets([top],[right],[bottom],[left]));

sorry for this quick answer .., if you have any problem you can ask me ;)

like image 40
Smaillns Avatar answered Nov 17 '22 05:11

Smaillns