forked from siblis/pocket-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
76 lines (61 loc) · 2.26 KB
/
Main.java
File metadata and controls
76 lines (61 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package client;
import client.view.Tray;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Cursor;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
public class Main extends Application {
public static Stage primaryStage;
private static BorderPane rootLayout;
private static final Logger mainLogger = LogManager.getLogger(Main.class);
@Override
public void start(Stage stage) {
primaryStage = stage;
primaryStage.setTitle("Pocket desktop client");
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/client/images/icon.png")));
//инициализируем главную сцену
initRootLayout();
//показываем общий вид
showOverview();
//значек в трее
Tray tray = new Tray();
tray.setTrayIcon();
primaryStage.setOnCloseRequest(event -> {
event.consume();
Tray.trayON(primaryStage);
});
}
public static void initRootLayout() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("/client/fxml/RootLayout.fxml"));
rootLayout = loader.load();
Scene scene = new Scene(rootLayout);
Cursor cursor = Cursor.cursor("HAND");
scene.setCursor(cursor);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
} catch (IOException e) {
mainLogger.error("initRootLayout_error", e);
}
}
public static void showOverview() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("/client/fxml/LogonView.fxml"));
AnchorPane overview = loader.load();
rootLayout.setCenter(overview);
} catch (IOException e) {
mainLogger.error("showOverview_error", e);
}
}
public static void main(String[] args){launch(args);}
}