setstyle how create and java css javafx treeview

how - set stylesheet javafx



Cómo deshabilitar o modificar el relleno de TreeCell en TreeView (0)

Entorno: JDK 7u75, Windows 8.1 x64, JavaFX2.2

Código de muestra:

public class TreeViewSample extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws MalformedURLException { primaryStage.setTitle("Tree View Sample"); TreeItem<String> rootItem = new TreeItem<String>("RootNode"); for (int i = 1; i < 5; i++) { TreeItem<String> item = new TreeItem<String>("SubNode" + i); rootItem.getChildren().add(item); item.getChildren().add(new TreeItem<String>("SubSubNode" + i + "" + i)); } rootItem.getChildren().add(new TreeItem<String>("SecondRootNode")); TreeView<String> tree = new TreeView<String>(rootItem); StackPane root = new StackPane(); root.getChildren().add(tree); Scene scene = new Scene(root, 300, 250); scene.getStylesheets().add((new File("../css/styletest.css").toURI()).toURL().toString()); primaryStage.setScene(scene); primaryStage.show(); } }

CSS:

.tree-cell { -fx-skin: "com.sun.javafx.scene.control.skin.TreeCellSkin"; -fx-background-color: -fx-control-inner-background; -fx-padding: 0.25em; /* 3 */ -fx-text-fill: -fx-text-inner-color; -fx-indent: 10; } .tree-cell .label { -fx-padding: 0.0em 0.0em 0.0em 0.25em; /* 0 0 0 3 */ } .tree-cell .tree-disclosure-node { -fx-padding: 4 2 4 8; -fx-background-color: transparent; } .tree-cell .tree-disclosure-node .arrow { -fx-background-color: -fx-mark-color; -fx-padding: 0.333333em; /* 4 */ -fx-shape: "M 0 -4 L 8 0 L 0 4 z"; }

Necesitamos eliminar todo el espacio y las flechas para todos los nodos. CSS modificado:

.tree-cell { -fx-skin: "com.sun.javafx.scene.control.skin.TreeCellSkin"; -fx-background-color: -fx-control-inner-background; -fx-padding: 0px; -fx-text-fill: -fx-text-inner-color; -fx-indent: 0px; } .tree-cell .label { -fx-padding: 0.0em 0.0em 0.0em 0.0em; } .tree-cell .tree-disclosure-node { -fx-padding: 0px; -fx-background-color: transparent; } .tree-cell .tree-disclosure-node .arrow { -fx-background-color: -fx-mark-color; -fx-padding: 0.0em; }

Como ve, no hay relleno y sangría para todos los nodos excepto hojas.

Y la pregunta: ¿cómo eliminar / modificar este relleno?