java - JavaFX CSS URL isn't loading -
i trying load xml resource, , doing this:
fxmlloader = new fxmlloader(); root = fxmlloader.load(getclass().getresource("document.fxml").openstream());
when run code error:
null/../css/button.css javafx.fxml.loadexception: unknown path:23
when @ line 23 have this:
<url value="@../css/button.css" />
this works:
fxmlloader = new fxmlloader(); root = fxmlloader.load(getclass().getresource("document.fxml"));
but when run following
controller = (documentcontroller)fxmlloader.getcontroller();
controller
null
how can fix css issue?
this bit of guess, think issue you're providing input stream fxmlloader
instead of url
. because of this, fxmlloader
unaware of location of fxml
resource, , hence can't resolve ..
in url tag. explain error message:
null/../css/button.css
javafx.fxml.loadexception:
unknown path:23
the path provided relative null
because fxmlloader doesn't know location of fxml file; notice reports "unknown path" source of fxml.
try (which more common anyway)
fxmlloader = new fxmlloader(getclass().getresource("document.fxml")); root = fxmlloader.load();
i'm figuring returns null controller because there error in loading fxml.
Comments
Post a Comment