点击工具栏的Project->Properties->Java Build Path->Libraries-> 双击第一项 点击Add添加允许javafx 然后就不会报错了 转载于:https://www.cnblogs.com/fu3638/p/8991492.html