Provide a "toWeb()" method for the Color class

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: fx2.1
    • Component/s: javafx

      I recently had to convert a javafx.util.Color to its web representation.

      What I ended up doing is, I used a substring of the toString() method and added the #.

      String style = "-fx-background-color: #" + color.toString().substring(2, color.get().toString().length() - 2);

      I also had to cut the alpha value.

      It might be helpful, if there was a method on the color object which converts it to the web color.

      Something like this:

      Color color = Color.BLUE;
      String webColor = color.toWeb(); // #0000FF

            Assignee:
            Unassigned
            Reporter:
            Christian Schudt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported: