javafxports项目中的FXML文件 [英] FXML file inside javafxports project
问题描述
我正在寻找有关javafxports技术的信息,可以在此项目的FXML文件中使用.
I'm looking information about javafxports technology and can I use inside this project FXML file.
这是我的build.gradle:
This is my 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第一页代码:
And this is my javaFX first page code:
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文件,并在具有Android操作系统的smartfon上运行我的应用程序.问题是,当我启动应用程序时,我只看到黑屏,什么都没有.
As we can see I use FXML file to define all my graphical structure (controls etc.). Everything compile ok. I also can create .apk file and run my application on smartfon with Android OS. The problem is when I start application I only see black screen , nothing else.
如果有人知道如何解决此问题,那么我会提供任何提示. 我需要逐步解决方案,因为胶子插件配置很困难.
If someone knows how fix this problem I am open on any tips. I need solution step by step because gluon plugin configuration is hard.
下面我展示了我的文件树:
Below I presents my file tree:
推荐答案
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");
这篇关于javafxports项目中的FXML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!