simply question (hopefully). possible add padding imageview using css in javafx? i've tried insets, padding etc without luck.
alternatively can same effect add text object. have explored google little success, not deal breaker makes things bit cleaner.
thank you.
-fx-padding
property of region.
an imageview
not region, therefore, cannot directly use padding on imageview. can place imageview in region provide padded area around imageview.
here sample uses stackpane (which style capable region). padding specified in fxml, equally work css.
in sample green border around image padding.
<?xml version="1.0" encoding="utf-8"?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.geometry.*?> <?import javafx.scene.image.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.paint.*?> <stackpane id="stackpane" maxheight="-infinity" maxwidth="-infinity" minheight="-infinity" minwidth="-infinity" prefheight="-1.0" prefwidth="-1.0" style="-fx-background-color: forestgreen;" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2"> <children> <imageview fitheight="150.0" fitwidth="200.0" pickonbounds="true" preserveratio="true"> <image> <image url="http://www.corwellphotography.net/image/2223982.jpeg" /> </image> </imageview> </children> <padding> <insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> </padding> </stackpane>
as stackpane or region can contain kind of node, technique works equally kind of node (not imageviews).
Comments
Post a Comment