所以我最近决定过渡到Java11。我正在尝试将GMapsFX API与Java11链接。我刚刚弄清楚了如何将Java11与JavaFX一起使用,并且能够显示和创建javaFXML文件,但是在尝试使用GMapsFX时出现错误。我正在使用NetBeans。
这是主要的:
def new_num(filename="varstore.dat"):
with open(filename, "a+") as f:
val = int(f.read() or 0) + 1
f.seek(0)
f.truncate()
f.write(str(val))
return val
}
这是HomePage.fxml文件文件:
package javaformcoursework;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class HomePage extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("HomePage.fxml"));
Scene scene = new Scene(root);
stage.setOpacity(0.9);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
控制器类没有代码,因此我没有显示。请记住,当我在FXML文件上没有GoogleMapView时,代码可以正常运行,并显示空白的锚定窗格。
这是错误:
<?xml version="1.0" encoding="UTF-8"?>
<?import com.lynden.gmapsfx.GoogleMapView?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0"
xmlns="http://javafx.com/javafx/9.0.1"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="javaformcoursework.HomePageController">
<children>
<GoogleMapView prefHeight="525.0" prefWidth="700.0" />
</children>
</AnchorPane>
非常感谢!
答案 0 :(得分:0)
对于IntelliJIDEA: 转到运行/调试配置,并将其添加到[VM options:] --module-path /YourPathToJavaFxLibs/javafx-sdk-11.0.1/lib --add-modules = javafx.controls,javafx.web,javafx.fxml