小编Joe*_*nst的帖子

在自包含JavaFX应用程序中包含图标

我一直在与这个战斗超过一天,并在SO和其他地方阅读了很多帖子,但我仍然遇到问题.

我需要在自包含的JavaFX应用程序包中包含我的应用程序图标.我正在使用JDK 1.8.0_45及其包含的JavaFX包.我正在使用Maven来构建.exe并且一切都很好,除了我不能得到我的图标.

这是我的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>

    <prerequisites>
        <maven>2.2.1</maven>
    </prerequisites>

    <groupId>com.mycompany.drm</groupId>
    <artifactId>DRMDashboard</artifactId>
    <version>2.0</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <javafx.version>8.0.45</javafx.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <!-- copy all dependencies of your app to target folder-->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <configuration>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <JavaFX-Version>${javafx.version}+</JavaFX-Version>
                            <Main-Class>com.mycompany.client.HelloWorld</Main-Class>
                            <implementation-version>2.0</implementation-version>
                            <JavaFX-Application-Class>com.mycompany.client.HelloWorld</JavaFX-Application-Class>
                            <JavaFX-Class-Path>
                                <!-- list all your dependencies …
Run Code Online (Sandbox Code Playgroud)

java javafx maven javafx-8

7
推荐指数
1
解决办法
5303
查看次数

如何将侦听器添加到 SplitPane Divider 位置?

我不知道如何在 JavaFX 8 SplitPane 上监听“Divider Repositioned”事件。这是一个简单的工作应用程序,只需要添加事件侦听器。有人可以帮助我指出正确的方向吗?

public class TestCase extends Application {
    public void start(Stage primaryStage) throws Exception {
        Pane leftPane = new Pane();
        Pane rightPane = new Pane();
        SplitPane splitPane = new SplitPane(leftPane, rightPane);

        // Need to create a listener that fires whenever the SplitPane's Divider is repositioned
        // Within this listener I need access to the leftPane and rightPane so I can call requestLayout()

        primaryStage.setScene(new Scene(splitPane));
        primaryStage.setWidth(800);
        primaryStage.setHeight(600);
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    } …
Run Code Online (Sandbox Code Playgroud)

listener splitpane javafx-8

5
推荐指数
1
解决办法
2457
查看次数

为什么线程阻塞了我的JavaFX UI线程?

当用户选择在另一个线程中启动阻止进程的菜单项时,我试图在JavaFX 8应用程序中提供反馈.在我的实际应用程序中,它是一个文件下载,但我通过示例使用最小代码创建了一个测试用例:

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.MenuButton;
import javafx.scene.control.ToolBar;
import javafx.scene.control.MenuItem;
import javafx.stage.Stage;

public class BlockingThreadTestCase extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        MenuItem menuItem = new MenuItem("Start");
        MenuButton menuButton = new MenuButton();
        menuButton.setText("Async Process");
        menuButton.getItems().addAll(menuItem);

        menuItem.setOnAction(event -> {
            menuButton.setText("Running...");

            Platform.runLater(() -> {
                try {
                    // Simulate a blocking process
                    Thread.sleep(5000);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                menuButton.setText(menuButton.getText() + "Done!");
            });
        });

        final ToolBar …
Run Code Online (Sandbox Code Playgroud)

java multithreading javafx-8

4
推荐指数
1
解决办法
3974
查看次数

JPA AttributeConverter被忽略

我正在尝试使用AttributeConverter使用Hibernate 4.3.0将新的Java 8 ZonedDateTime值存储在MySQL数据库(DATETIME字段)中.

当我尝试执行更新时,我收到此错误:

...Data truncation: Incorrect datetime value: '\xAC\xED\x00\x05sr\x00\x0Djava.time.Ser\x95]\x84\xBA\x1B"H\xB2\x0C\x00\x00xpw\x0D\x06\x00\x00\x07\xE0\x02\x11\x0B&\xEE\xE0\x08\x' for column...
Run Code Online (Sandbox Code Playgroud)

我已经阅读了许多SO答案,说使用转换器方法,所以我写了一个:

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.sql.Date;
import java.time.LocalDate;
import java.time.ZonedDateTime;

@Converter(autoApply = true)
public class ZonedDateTimeConverter implements AttributeConverter<ZonedDateTime, Date> {
    @Override
    public Date convertToDatabaseColumn(ZonedDateTime zonedDateTime) {
        if (zonedDateTime == null) return null;

        return java.sql.Date.valueOf(zonedDateTime.toLocalDate());
    }

    @Override
    public ZonedDateTime convertToEntityAttribute(Date date) {
        if (date == null) return null;

        LocalDate localDate = date.toLocalDate();
        return ZonedDateTime.from(localDate);
    }
}
Run Code Online (Sandbox Code Playgroud)

......但它永远不会被召唤.

我甚jpaProperties.put("hibernate.archive.autodetection", "class, hbm");至已添加到我的jpaProperties,但没有运气.ZonedDateTimeConverter类与我的实体位于同一个包中,因此应该扫描它.

我在这里错过了什么?

java hibernate jpa java-8

0
推荐指数
1
解决办法
2596
查看次数

标签 统计

java ×3

javafx-8 ×3

hibernate ×1

java-8 ×1

javafx ×1

jpa ×1

listener ×1

maven ×1

multithreading ×1

splitpane ×1