我正在寻找关于javafxports技术的信息,我可以在这个项目中使用FXML文件。
这是我的build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.1.0'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.orden.First'
dependencies {
compile 'com.gluonhq:charm:4.0.0'
// Desktop SQL -> https://github.com/xerial/sqlite-jdbc
desktopRuntime 'org.xerial:sqlite-jdbc:3.8.11.2'
embeddedRuntime 'com.gluonhq:charm-down-plugin-storage-desktop:3.0.0'
// Embedded SQL -> https://github.com/xerial/sqlite-jdbc
embeddedRuntime 'org.xerial:sqlite-jdbc:3.7.2'
// Android SQL -> https://github.com/SQLDroid/SQLDroid
androidRuntime 'org.sqldroid:sqldroid:1.0.3'
// ios SQL -> https://github.com/robovm/robovm 1.8
}
jfxmobile {
downConfig {
version = '3.0.0'
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'C:/Program Files (x86)/Android/android-sdk/'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*',
'SQLite.**.*'
]
}
embedded {
remotePlatforms {
raspberry {
host = '192.168.1.10'
username = 'pi'
password = 'raspberry'
workingDir = '/home/pi/Gluon'
jreLocation = '/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt'
execPrefix = 'sudo'
}
}
}
}这是我的javaFX首页代码:
package com.orden;
import java.io.File;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Screen;
import javafx.stage.Stage;
public class First extends Application {
public void start(Stage primaryStage) {
try {
URL url = new File("src/main/java/com/orden/views/MainWindowFXML.fxml").toURL();
URL url2 = new File("src/main/java/com/orden/views/application.css").toURL();
AnchorPane root = (AnchorPane)FXMLLoader.load(url);
Scene scene = new Scene(root);
scene.getStylesheets().add(url2.toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setTitle("Image saver");
primaryStage.setResizable(true);
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
} 正如我们所看到的,我使用FXML文件来定义我所有的图形结构(控件等)。一切编译正常。我也可以创建.apk文件和运行我的应用程序在smartfon与安卓操作系统。问题是当我启动应用程序时,我只看到黑屏,没有其他的。
如果有人知道如何解决这个问题,我对任何提示都持开放态度。我需要一步一步的解决方案,因为胶水插件配置是困难的。
下面我展示了我的文件树:

发布于 2017-01-13 10:46:22
URL url = getClass().getResource("views/MainWindowFXML.fxml");
URL url2 = getClass().getResource("views/application.css");或
URL url = getClass().getResource("/com/orden/views/MainWindowFXML.fxml");
URL url2 = getClass().getResource("/com/orden/views/application.css");或
URL url = getClass().getClassLoader().getResource("com/orden/views/MainWindowFXML.fxml");
URL url2 = getClass().getClassLoader().getResource("com/orden/views/application.css");https://stackoverflow.com/questions/41626292
复制相似问题