JavaFX 8应用程序不显示其应用程序图标

时间:2017-08-26 07:47:01

标签: eclipse debian javafx-8

我正在尝试为我的JavaFX 8应用程序设置一个图标,但图标未显示。 试图理解这个问题我用一个Main类创建了一个非常简单的应用程序。 这是它的代码:

package application;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;


public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        StageStyle style = primaryStage.getStyle();
        // style == StageStile.DECORATED

        try {
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog16.png"))); // iconSize == 16x16px
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog22.png"))); // iconSize == 22x22px
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog24.png"))); // ...
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog32.png")));
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog48.png")));
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog16.png")));
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog64.png")));
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog128.png")));
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog256.png")));
            primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("phog512.png")));

            int size = primaryStage.getIcons().size();
            // size == 10

            BorderPane root = new BorderPane();
            Scene scene = new Scene(root,400,400);
            scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.setTitle("Application Icon");

            primaryStage.show();
        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

由于应用程序输出显示没有应用程序图标: application output

我的环境: Debian 9.1(Stretch)64bit Gnome; 蚀-SDK-4.7-Linux的GTK的x86_64的; JDK-8u144-Linux的64

我做错了什么?

0 个答案:

没有答案
相关问题