编程语言
首页 > 编程语言> > 烦死人的JavaFX警告,终于解决了

烦死人的JavaFX警告,终于解决了

作者:互联网

WARNING: Loading FXML document with JavaFX API of version xx by JavaFX runtime of version xx

这个格式的JavaFX警告,用过JavaFX的一些小伙伴可能见过这个警告。虽然不影响程序运行,但是实在不美观。在我这里,这个警告是这样的

为了解决这个警告,我是煞费苦心。最终还是万能的stackoverflow给了我答案

(原stackoverflow贴地址—>点我

 Your FXML file has an xmlns="http://javafx.com/javafx/10.0.1 attribute in the root element. This is automatically added by Scene Builder. If you simply get rid of the 10.0.1, or replace it with 8.0.241, then the warning will go away. The version added by Scene Builder corresponds to the version of Scene Builder itself, since the tool's capabilities are determined by which version of JavaFX it was built for. The warning is simply telling you that if you used JavaFX APIs which require 10.0.1 then the application will fail on earlier versions 

啥意思呢?意思就是,在你的fxml文件中有xmlns="http://javafx.com/javafx/10.0.1 这样一行。而我的是xmlns="http://javafx.com/javafx/17

 为啥不一样呢?因为这个值是由Scene Builder编辑FXML文件的时候自动添加的。在程序运行时这个值会被拿来和JDK版本进行比对。这个值取决于你用的Scene Builder版本。我用的是17那么这个值就是xmlns="http://javafx.com/javafx/17 

由于我用的是jdk10,10和17对不上,于是产生了上面的警告。解决方法很简单,把xmlns的值改成你jdk版本就OK啦。

可以看到,改了版本之后,确实没有警告了。就喜欢清爽的感觉,哈哈 

标签:烦死人,xmlns,JavaFX,Builder,javafx,Scene,version,警告
来源: https://blog.csdn.net/DYxiao666/article/details/122396866