[英]Setting a custom icon on javafx application
我正在尝试在macOS上构建本机包,并添加自定义图标,而不是默认Java。
我将我的128x128 icns文件放在src / main / deploy / package / macosx中,在pom.xml中添加javafx-maven-plugin并运行命令mvn jfx:build-native(或mvn jfx:native)。 没有任何反应。 表示它已成功构建,但仍使用默认图标。 我做错了什么?
这是我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>StarWars</groupId>
<artifactId>Minesweeper</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>example.minesweeper.Main</mainClass>
<application.title>${project.artifactId}</application.title>
<copyright>Han Solo</copyright>
</properties>
<organization>
<name>Star Wars</name>
</organization>
<name>Minesweeper</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-core</artifactId>
<version>4.0.6-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit</artifactId>
<version>4.0.6-alpha</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<vendor>AndreySerebryanskiy</vendor>
<mainClass>example.minesweeper.Main</mainClass>
<deployDir>${project.basedir}/src/main/deploy</deployDir>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是我的项目结构的屏幕截图。
顺便说一句,我正在使用IntelliJ IDEA 2017.1.4。 我也看到了以下问题:
我还看到了在NetBeansIDE中完成此任务的简单方法(例如here )。 但是由于这种简单的问题,我不想更改IDE。 先感谢您!
打开详细模式后,我发现它期望使用Minesweeper-1.0.icns而不是Minesweeper.icns。 在没收javafx-maven-plugin的情况下添加appName字段解决了我的问题。
您将必须添加到javafx-maven-plugin配置中。
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<vendor>AndreySerebryanskiy</vendor>
<mainClass>example.minesweeper.Main</mainClass>
<deployDir>${project.basedir}/src/main/deploy</deployDir>
<verbose>true</verbose><!-- always a good idea to have this set to true while debugging -->
<appName>Minesweeper</appName>
</configuration>
</plugin>
请确保您的ICNS文件名与<appName>
内部的文件名相同,然后只需调用mvn jfx:native
即可捆绑您的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.