JavaFX 2 debug css

I am struggling with some CSS style when working with JavaFX ..

I wonder if there is a way to debug css?

somthing, like firebug or a built-in tool in chrome that shows you when you click on an element to which CSS styles apply.

+5
source share
2 answers

Check out the Scenic View to see how it fits your needs, at least.

+4
source

In addition to using ScenicView as suggested by Uluk, sometimes I also just delete the active nodes in the console after showing Stage. This default value toString()for nodes lists their identifiers and css class classes.

// debugging routine to dump the scene graph.
public  static void dump(Node n) { dump(n, 0); }
private static void dump(Node n, int depth) {
  for (int i = 0; i < depth; i++) System.out.print("  ");
  System.out.println(n);
  if (n instanceof Parent) 
    for (Node c : ((Parent) n).getChildrenUnmodifiable()) 
      dump(c, depth + 1);
}

Output Example:

BorderPane@13c3750
  Text@2e3919[styleClass=lyric-text]
  Button[id=null, styleClass=button change-lyric]
    ButtonSkin[id=null, styleClass=button change-lyric]
      ImageView@13a4e73
      LabeledText@567aef[styleClass=text]

api css, .

api public : CSS Style Object Model Java. StyleMap node, , css node, StyleMap.

public void addStyleMaps(Node node, int depth) {
  node.impl_setStyleMap(FXCollections.observableMap(new HashMap<WritableValue, List<Style>>()));
  if (node instanceof Parent) {
    for (Node child : ((Parent) node).getChildrenUnmodifiable()) {
      addStyleMaps(child, depth + 1);
    }
  }
}

value = >

System.out.println(n + " " + node.impl_getStyleMap());

, .

, impl_ api, , (, , ) JavaFX api.

, , , ScenicView, CSS- Firebug. , ScenicView , css , .

+3

All Articles