1

When I run my application, it does not display the same button as scenebuilder does.

Scenebuilder Screenshot

sb

MyApp Screenshot

ma

I naturally saved the files and tried to restart, to no avail. I use IntelliJ but I've been following a tutorial using the same IDE as I do, so there should be no issue about it.

Help would be much appreciated, folks. Thank you :)

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • 2
    My guess is the path to the CSS file is incorrect. It's relative to the working directory of Scene Builder, but that same relative path doesn't work when the working directory changes (e.g. when running in the IDE). Make the FXML and CSS files resources of your application (e.g. if using Maven/Gradle, somewhere under `src/main/resources`), and then use the appropriate `@` that points to the CSS file (check out [this documentation](https://openjfx.io/javadoc/17/javafx.fxml/javafx/fxml/doc-files/introduction_to_fxml.html#location_resolution)). – Slaw Dec 27 '21 at 23:15
  • 1
    Hmm, there is a red message partially hidden behind the screenshot, I think that might be important for you to resolve. – jewelsea Dec 28 '21 at 02:06
  • Study the [eden coding resource guide](https://edencoding.com/where-to-put-resource-files-in-javafx/) sections on CSS file resolution, also see: [How do I determine the correct path for FXML files, CSS files, Images, and other resources needed by my JavaFX Application?](https://stackoverflow.com/questions/61531317/how-do-i-determine-the-correct-path-for-fxml-files-css-files-images-and-other) – jewelsea Dec 28 '21 at 02:08
  • Actually I found out that it was because the intelliJ community version does not support CSS. The guy in the tutorial probably possessed the ultimate version of IntelliJ. Thanks for the help though – Louis Lhotte Dec 28 '21 at 14:33
  • It doesn't matter that IntelliJ community does not provide full support for CSS. That only has to do with syntax highlighting, autocompletion, and so on. You can still create and edit CSS files using IntelliJ, because they are just plain text files. Plus, keep in mind that [tag:javafx-css] is based on, but not quite the same as, "real" [tag:css]. – Slaw Dec 28 '21 at 20:20
  • With all that said, the IDE will still include the CSS file in your build assuming you've saved it in your resources directory and the IDE is aware of that directory. And JavaFX loading CSS resources is entirely independent of the IDE you're using. – Slaw Dec 28 '21 at 20:23

0 Answers0