Používám NumberFormat formátovat desetinná čísla na Italien ve formátu (10000 -> 10.000), funguje, jak se očekávalo, ale když jsem balíček moje aplikace pomocí Jlink pořádné plugin, zobrazí se všechna čísla v americkém formátu (10,000) (událost tho jsem si Italien formátu v mém kódu)
pro zjednodušení problému jsem udělal jednoduchou hello world aplikaci, která ilustruje problém :
Hlavní Třída
public class HelloApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
Regulátor
public class HelloController {
@FXML
private Label welcomeText;
@FXML
protected void onHelloButtonClick() {
NumberFormat nf = NumberFormat.getNumberInstance(Locale.ITALIAN);
DecimalFormat formatter = (DecimalFormat) nf;
formatter.applyPattern("#,###");
welcomeText.setText(formatter.format(56465465));
}
}
Fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
fx:controller="com.example.demo4.HelloController">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
</padding>
<Label fx:id="welcomeText"/>
<Button text="Hello!" onAction="#onHelloButtonClick"/>
</VBox>
Gradle.Stavět
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version '2.24.4'
}
group 'com.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
ext {
junitVersion = '5.7.1'
}
sourceCompatibility = '17'
targetCompatibility = '17'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'com.example.demo4'
mainClass = 'com.example.demo4.Runner'
}
javafx {
version = '17-ea+11'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
jlink {
jpackage{
imageOptions = ["--icon", "C:/demo4/src/main/resources/com/example/demo4/Icon.ico"]
}
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'Karrty'
}
}
Výsledky
při sestavování a provádění kódu, štítek ukazuje : 56.465.465
zatímco běží .exe soubor (vytvořený Jlink pořádné plugin), štítek ukazuje : 56,465,465