Skip to content

Commit f2a4ecf

Browse files
committed
修复编译错误,应用全局样式和 LOGO
1 parent 2532b2c commit f2a4ecf

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

  • src/main/java/com/xwintop/xJavaFxTool

src/main/java/com/xwintop/xJavaFxTool/Main.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import com.xwintop.xJavaFxTool.utils.Config;
66
import com.xwintop.xJavaFxTool.utils.StageUtils;
77
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
8+
import com.xwintop.xcore.FxApp;
89
import com.xwintop.xcore.util.javafx.AlertUtil;
910
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
11+
import java.util.ResourceBundle;
1012
import javafx.application.Application;
1113
import javafx.application.Platform;
1214
import javafx.event.Event;
@@ -17,8 +19,6 @@
1719
import javafx.stage.Stage;
1820
import lombok.extern.slf4j.Slf4j;
1921

20-
import java.util.ResourceBundle;
21-
2222
/**
2323
* @ClassName: Main
2424
* @Description: 启动类
@@ -28,7 +28,7 @@
2828
@Slf4j
2929
public class Main extends Application {
3030

31-
public static final String PREFERENCE_ROOT = "com.xwintop.xJavaFxTool";
31+
public static final String LOGO_PATH = "/images/icon.jpg";
3232

3333
private static Stage stage;
3434

@@ -43,6 +43,11 @@ public static void main(String[] args) {
4343

4444
@Override
4545
public void start(Stage primaryStage) throws Exception {
46+
47+
// 初始化 JavaFX 全局设置
48+
FxApp.init(primaryStage, LOGO_PATH);
49+
FxApp.styleSheets.add(Main.class.getResource("/css/jfoenix-main.css").toExternalForm());
50+
4651
XJavaFxSystemUtil.initSystemLocal();//初始化本地语言
4752
XJavaFxSystemUtil.addJarByLibs();//添加外部jar包
4853

@@ -51,18 +56,18 @@ public void start(Stage primaryStage) throws Exception {
5156
Parent root = fXMLLoader.load();
5257

5358
JFXDecorator decorator = JavaFxViewUtil.getJFXDecorator(
54-
primaryStage,
55-
resourceBundle.getString("Title") + Config.xJavaFxToolVersions,
56-
"/images/icon.jpg",
57-
root
59+
primaryStage,
60+
resourceBundle.getString("Title") + Config.xJavaFxToolVersions,
61+
LOGO_PATH,
62+
root
5863
);
5964
decorator.setOnCloseButtonAction(() -> confirmExit(null));
6065

6166
Scene scene = JavaFxViewUtil.getJFXDecoratorScene(decorator);
6267

6368
primaryStage.setResizable(true);
6469
primaryStage.setTitle(resourceBundle.getString("Title"));//标题
65-
primaryStage.getIcons().add(new Image("/images/icon.jpg"));//图标
70+
primaryStage.getIcons().add(new Image(LOGO_PATH));//图标
6671
primaryStage.setScene(scene);
6772
primaryStage.setOnCloseRequest(this::confirmExit);
6873

@@ -75,7 +80,7 @@ public void start(Stage primaryStage) throws Exception {
7580

7681
private void confirmExit(Event event) {
7782
if (XJavaFxSystemUtil.getSystemConfigure().getBoolean("exitShowAlertCheckBox", true)) {
78-
if (AlertUtil.showConfirmAlert("确定要退出吗?")) {
83+
if (AlertUtil.confirmOkCancel("退出应用", "确定要退出吗?")) {
7984
StageUtils.savePrimaryStageBound(stage);
8085
Platform.exit();
8186
System.exit(0);

0 commit comments

Comments
 (0)