Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8088028

Node#getStyle()/setStyle() are not very friendly.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • javafx
    • None

      in javascript any object is a hash table, to set or get style properties I can

      if (node.style.color === "blue")
        node.style.color = "red";
      else
        node.style.color = "blue";


      Try doing the same using JFX API;

      The same, incomlete

      String key = "-fx-fill:";
      String style = text.getStyle();
      int index = style.indexOf(key);//assume is always there;
      int endIndex = style.indexOf(";", index);//assume is always there
      String value = style.substring(index + key.length(), endIndex).trim();
      String newStyle = style.substring(0, index) + style.substring(endIndex + 1);
      if (value.equals("red")) {
          newStyle += "-fx-fill: blue;";
      } else {
          newStyle += "-fx-fill: red;";
      }
      text.setStyle(newStyle);


            Unassigned Unassigned
            fheidric Felipe Heidrich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported: