import com.sun.javafx.runtime.VersionInfo; import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; /** * Created with IntelliJ IDEA. * User: slugovoy * Date: 26.09.13 * Time: 16:01 * To change this template use File | Settings | File Templates. */ public class TreeViewCellSizeTest extends Application { private String style = "-fx-cell-size:100px;"; /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { BorderPane pane = new BorderPane(); TreeItem root = new TreeItem("ROOT", new Rectangle(20, 20, Color.CHOCOLATE)); root.setExpanded(true); TreeItem firstBrunch = new TreeItem("brunch 1"); firstBrunch.setExpanded(true); firstBrunch.getChildren().addAll(new TreeItem("first item"), new TreeItem("second item", new Rectangle(20, 20, Color.DARKGREY))); root.getChildren().addAll(firstBrunch); TreeItem secondBrunch = new TreeItem("brunch 2"); secondBrunch.getChildren().addAll(new TreeItem("first item"), new TreeItem("second item", new Rectangle(20, 20, Color.DARKGREY))); root.getChildren().addAll(secondBrunch); final TreeView tree = new TreeView(root); tree.setFocusTraversable(false); Executors.newScheduledThreadPool(1).schedule(new Runnable() { @Override public void run() { Platform.runLater(new Runnable() { @Override public void run() { tree.setStyle(style); System.out.println("style is set"); } }); } }, 5, TimeUnit.SECONDS); pane.setCenter(new VBox(50) {{ getChildren().addAll(new Button("Button"), tree); setFillWidth(false); }}); Scene scene = new Scene(pane, 500, 400); stage.setScene(scene); stage.show(); stage.setTitle(VersionInfo.getRuntimeVersion()); } }