Skip to content

Commit 13b43f9

Browse files
committed
fit:修改keyTool工具类启动方法
1 parent f43deff commit 13b43f9

2 files changed

Lines changed: 53 additions & 28 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.xwintop.xJavaFxTool;
2+
3+
import com.xwintop.xcore.util.javafx.JavaFxSystemUtil;
4+
import javafx.application.Application;
5+
import javafx.event.EventHandler;
6+
import javafx.fxml.FXMLLoader;
7+
import javafx.scene.Parent;
8+
import javafx.scene.Scene;
9+
import javafx.stage.Stage;
10+
import javafx.stage.WindowEvent;
11+
import lombok.extern.slf4j.Slf4j;
12+
13+
import java.net.URL;
14+
import java.util.ResourceBundle;
15+
16+
@Slf4j
17+
public class KeyToolApplication extends Application {
18+
public static void main(String[] args) {
19+
try {
20+
launch(args);
21+
} catch (Exception e) {
22+
e.printStackTrace();
23+
}
24+
}
25+
26+
@Override
27+
public void start(Stage primaryStage) throws Exception {
28+
FXMLLoader fXMLLoader = KeyToolApplication.getFXMLLoader();
29+
// ResourceBundle resourceBundle = fXMLLoader.getResources();
30+
Parent root = fXMLLoader.load();
31+
primaryStage.setResizable(true);
32+
// primaryStage.setTitle(resourceBundle.getString("Title"));
33+
// primaryStage.getIcons().add(new Image("/images/icon.jpg"));
34+
double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74, 0.8);
35+
primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1]));
36+
primaryStage.show();
37+
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
38+
@Override
39+
public void handle(WindowEvent event) {
40+
System.exit(0);
41+
}
42+
});
43+
}
44+
45+
public static FXMLLoader getFXMLLoader() {
46+
ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.KeyTool");
47+
URL url = KeyToolApplication.class.getClassLoader().getResource("com/xwintop/xJavaFxTool/fxmlView/debugTools/KeyTool.fxml");
48+
FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle);
49+
return fXMLLoader;
50+
}
51+
}

debugTools/x-KeyTool/src/main/java/com/xwintop/xJavaFxTool/KeyToolMain.java

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,12 @@
1414
import java.util.ResourceBundle;
1515

1616
@Slf4j
17-
public class KeyToolMain extends Application {
17+
public class KeyToolMain {
1818
public static void main(String[] args) {
1919
try {
20-
launch(args);
20+
Application.launch(KeyToolApplication.class, args);
2121
} catch (Exception e) {
2222
e.printStackTrace();
2323
}
2424
}
25-
26-
@Override
27-
public void start(Stage primaryStage) throws Exception {
28-
FXMLLoader fXMLLoader = KeyToolMain.getFXMLLoader();
29-
ResourceBundle resourceBundle = fXMLLoader.getResources();
30-
Parent root = fXMLLoader.load();
31-
primaryStage.setResizable(true);
32-
primaryStage.setTitle(resourceBundle.getString("Title"));
33-
// primaryStage.getIcons().add(new Image("/images/icon.jpg"));
34-
double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74, 0.8);
35-
primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1]));
36-
primaryStage.show();
37-
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
38-
@Override
39-
public void handle(WindowEvent event) {
40-
System.exit(0);
41-
}
42-
});
43-
}
44-
45-
public static FXMLLoader getFXMLLoader() {
46-
ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.KeyTool");
47-
URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/debugTools/KeyTool.fxml");
48-
FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle);
49-
return fXMLLoader;
50-
}
5125
}

0 commit comments

Comments
 (0)