Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing this library from Gluon's SceneBuilder? #14

Open
seinecle opened this issue Apr 12, 2020 · 2 comments
Open

Accessing this library from Gluon's SceneBuilder? #14

seinecle opened this issue Apr 12, 2020 · 2 comments
Labels

Comments

@seinecle
Copy link

seinecle commented Apr 12, 2020

I'd like to use this bootstrap css framework, but accessed through the Gluon SceneBuilder. I see there is an "add css stylesheet" in the menu of the SceneBuilder but I am not sure how this can be combined with the add-on mentioned above?
Also asked on SO: https://stackoverflow.com/questions/61170165/add-a-bootstrap-css-stylesheet-to-gluon-scenebuilder-for-javafx

@SessionESP
Copy link

I spent several hours investigating this question and finally I have to reference as usual stylesheet from project resources:
scene_builder

"bootstrapfx.css" is a copy from the Maven .jar

I've tried to use Gluon Scene Builder, whitch it is said to have Maven suport to import dependencies, but it is too much unstable software so I returned to classic Oracle JavaFX Scene Builder.

@juananpe
Copy link

juananpe commented Jan 21, 2023

I'm aware that this question was asked more than a year ago, but I'd like to share how I solved it... and honestly, because in the process I stumbled upon a related problem and perhaps someone can enlighten me with a solution, see below :)

To use BootstrapFX in SB and preview the results, I can do the following (as seen in @aalmiray answer here: https://stackoverflow.com/a/64404062/243532):

  • Open my FXML file (hello-view.fxml) in SB
  • Open the JAR/FXML manager

image

Add the org.kordamp.bootstrapfx:bootstrap-core:0.4.0 JAR from Maven (using the "Manually add Library from repository")

image

Set the bootstrapfx.css stylesheet to the root node of the scene. For that, I assumed the following:
image

  • the bootstrapfx.css is available in the /org/kordamp/bootstrapfx/bootstrapfx.css path

I needed to click on "Switch to classpath relative path" and add the full path to the file:
image

Now I can see all the available CSS styles and apply them from SB to any of the scene's nodes:

image

So far so good. However, when I open the FXML file in IntelliJ (where I have the BootstrapFX library defined as a dependency in Maven) I get this error:

image

Cannot resolve directory 'org': (I'm assuming that stylesheets="@/org/kordamp/bootstrapfx/bootstrapfx.css" should look into the proper JAR dependency in my Maven external libraries and get the CSS file from there... in fact, isn't it what was really happening in SB?)

And of course, when I run the application from IntelliJ, it yields this error:

Caused by: javafx.fxml.LoadException: Invalid resource: /org/kordamp/bootstrapfx/bootstrapfx.css not found on the classpath

Is there any way to specify in the stylesheets attribute the path to a CSS file located inside a JAR file so we can run the JavaFX application without errors both in SB and from IntelliJ/Maven?

PD: I've also posted this last question in StackOverflow:
https://stackoverflow.com/questions/75195364/cant-use-a-css-located-inside-a-jar-file-in-an-javafx-fxml-scene

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants