Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. JavaFX CSS "dynamic" value not being used

JavaFX CSS "dynamic" value not being used

Scheduled Pinned Locked Moved Java
helpjavacssjsonquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Valentinor
    wrote on last edited by
    #1

    I'm having a weird problem with my CSS. If I go into the file and set the following two properties manually, it is working, but if I set them from java code (.setStyle()), for some reason they aren't being used. Properties: -fx-font-family -fx-font-size So if in the file I use the following syntax it is working fine:

    -fx-font-family: "Blackadder ITC";
    -fx-font-size: 18;

    I used that font family because it is clear to see if it is changed or not. Then I changed that with the following set to be able to change the font (family and size) straight from my java code.

    -fx-font-family: fontFam;
    -fx-font-size: fontDim;

    In java code I have this:

    String fontFam = "Blackadder ITC";
    int fontDim = 18;
    .setStyle("fontFam: \"" + fontFam + "\"; fontDim: " + fontDim + ";");

    I have other css properties in this .setStyle (to set some rgba colors), and they are working fine, the problem is only with the font. The first problem is that the font family doesn't get applied, and the second one is the font size, I'm getting the following warning: WARNING: CSS Error parsing file: file location: Expected '' while parsing '-fx-font-size' at [6,16] Unfortunately I can't simply use .setFont for this, because it is part of DataPicker, more precise it's TextField. Isn't this the way you are suppose to do it, or for font property I have to do something different?

    V 1 Reply Last reply
    0
    • V Valentinor

      I'm having a weird problem with my CSS. If I go into the file and set the following two properties manually, it is working, but if I set them from java code (.setStyle()), for some reason they aren't being used. Properties: -fx-font-family -fx-font-size So if in the file I use the following syntax it is working fine:

      -fx-font-family: "Blackadder ITC";
      -fx-font-size: 18;

      I used that font family because it is clear to see if it is changed or not. Then I changed that with the following set to be able to change the font (family and size) straight from my java code.

      -fx-font-family: fontFam;
      -fx-font-size: fontDim;

      In java code I have this:

      String fontFam = "Blackadder ITC";
      int fontDim = 18;
      .setStyle("fontFam: \"" + fontFam + "\"; fontDim: " + fontDim + ";");

      I have other css properties in this .setStyle (to set some rgba colors), and they are working fine, the problem is only with the font. The first problem is that the font family doesn't get applied, and the second one is the font size, I'm getting the following warning: WARNING: CSS Error parsing file: file location: Expected '' while parsing '-fx-font-size' at [6,16] Unfortunately I can't simply use .setFont for this, because it is part of DataPicker, more precise it's TextField. Isn't this the way you are suppose to do it, or for font property I have to do something different?

      V Offline
      V Offline
      Valentinor
      wrote on last edited by
      #2

      I've done some more testing, and I got some strange results. I tried the following code, and it wasn't working either for font.

      * {
      fontFO: "Blackadder ITC";
      fontSI: 18;
      }

      .date-picker > .text-field {
      -fx-font-family: fontFO;
      -fx-font-size: fontSI;
      }

      The fontFO didn't had any effect, it used it's default font family, and using the fontSI, I was getting the same warring as in my previous post. So I'm left with 2 questions. 1. Can you use "looked-up"/dynamic values (or how they are actually named, I'm not that good at CSS), only for colors? 2. What other choice/method do I have to send values to a CSS file? I want to give the option to the user to change the font family and font size to whatever they want.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups