0

I am just learning scalaFX/javaFX after years with swing and months with scalaSwing. ScalaSwing had a few little issues that I felt weren't worth dealing with given the opportunity to update to something current. It Doesn't surprise me that I am having issues, but I am concerned.

Is this a problem with something I'm doing? I need black backgrounds and this seems to be failing and not telling me why.

I can sort of get this to work if I add the button first then a rectangle. I have tried wrapping the rectangle, but that is not the solution.

Thanks!

object Broken extends JFXApp {

  stage = new PrimaryStage {
    x = 0
    y = 0
    scene = new Scene {
      stylesheets add getClass.getResource("Dark.css").toExternalForm
      root = new FlowPane {
        padding = Insets(10)
        children = List(new Rectangle() {
          x = 0
          y = 0
          width = 100
          height = 150
          arcHeight = 20
          arcWidth = 20
          fill = Color.Red
        })
      }
    }
  }
}


object Works extends JFXApp {

  stage = new PrimaryStage {
    x = 0
    y = 0
    scene = new Scene {
      stylesheets add getClass.getResource("Dark.css").toExternalForm
      root = new FlowPane {
        padding = Insets(10)
        children = List(new Button("Works"))
      }
    }
  }
}

With this as Dark.css (file) in the same package

 //Dark.css
.root{
    -fx-font-size: 14pt;
    -fx-font-family: "Courier New";
    -fx-base: rgb(25,25,65);
    -fx-background: rgb(0, 0, 0);
}
Bday
  • 1,005
  • 7
  • 13
  • I get the feeling that there is something intrinsic I'm missing, because if I just add and empty pane (StackPane) I get white, and I would think that I should always get black. But if I add the Button I get Black. So there is some content requirement? – Bday Jun 13 '16 at 18:35
  • How about you need some element that is Skinnable? Button and Label both are and their inclusion makes the styles work. In the end I need plenty of things that will extend Skinnable, so maybe this test is too focused. – Bday Jun 13 '16 at 19:05
  • Where is the`Dark.css` file located? – Eugene Ryzhikov Jun 14 '16 at 13:31
  • I put the Dark.css on the end of the post. – Bday Oct 03 '16 at 20:28
  • I mean it is physical location – Eugene Ryzhikov Oct 03 '16 at 21:28
  • There are various post here about that. There are two choices about how to apply the css also. Application.setUserAgentStylesheet(getClass.getResource("Dark.css").toExternalForm) with the Dark.css file in the same package as the test class will work. – Bday Oct 04 '16 at 16:57

0 Answers0