javafxとCSSファイルを使用して小さなプログラムを作成し始めています。netbeansからプログラムを実行すると背景が変わりますが、jarファイル「DIST」の背景をフォルダに作成NetBeansは、私はあなたの助けコードjavafxのエクスポートされた実行可能なjarファイルでCSSスタイルが機能しない
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package finalfx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
/**
*
*/
public class FinalFX extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
stage.getIcons().add(new Image("patient-icon-8.ico"));
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
以下
を必要としてください消えたことを//////////////////// //////
CSSコード
.root {
-fx-background-image: url("84770f_6b54c02021f64aa38d05264a9afc3f80[1].jpg");
-fx-background-repeat: stretch;
-fx-background-size: 1904 1001;
-fx-background-position: center;
}
私はこれを試してみましたが、まだ同じフォルダ –