Repository navigation
Expand file tree
/
Copy pathMainApp.java
More file actions
161 lines (142 loc) · 5.02 KB
/
Copy pathMainApp.java
File metadata and controls
161 lines (142 loc) · 5.02 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package BookManageSystem;
import BookManageSystem.controller.LoginFrameController;
import BookManageSystem.controller.SoftInformationFrameController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.io.IOException;
public class MainApp extends Application{
private Stage primaryStage;
@Override
public void start(Stage stage) {
this.primaryStage = stage;
this.primaryStage.setTitle("图书馆管理系统");
initLoginFrame();
}
public static void main(String[] args) {
launch(args);
}
/**
* 登录界面
*/
private void initLoginFrame(){
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("view/loginFrame.fxml"));
AnchorPane root = loader.load();
Scene scene = new Scene(root);
primaryStage.setTitle("登录");
primaryStage.setScene(scene);
primaryStage.setResizable(false); //不可调整窗口大小
LoginFrameController controller = loader.getController();
controller.setStage(primaryStage);
primaryStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 主界面
*/
public void initMainFrame() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("view/mainFrame.fxml"));
AnchorPane root = loader.load();
//设置stage舞台属性
Stage mainFrameStage = new Stage();
mainFrameStage.setTitle("图书馆管理系统主界面");
mainFrameStage.setResizable(true); //可自由改变窗口大小
mainFrameStage.setAlwaysOnTop(false); //窗口不会永远置于前端
mainFrameStage.initModality(Modality.APPLICATION_MODAL); //阻止输入事件从同一应用程序传递到所有窗口的阶段,除了其子层次结构中的事件
mainFrameStage.initOwner(primaryStage); //指定父窗口
Scene scene = new Scene(root);
mainFrameStage.setScene(scene);
mainFrameStage.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 图书类别添加界面
* @return 返回一个AnchorPane, 便于其他空间调用
*/
public AnchorPane initBookTypeAddFrame() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("view/bookTypeAddFrame.fxml"));
return loader.load();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 图书类别管理界面
* @return 返回AnchorPane, 便于其他控件调用
*/
public AnchorPane initBookTypeManageFrame() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("view/bookTypeManageFrame.fxml"));
try {
return loader.load();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 图书添加界面
* @return AnchorPane, 便于其他控件调用
*/
public AnchorPane initBookAddFrame() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("view/bookAddFrame.fxml"));
try {
return loader.load();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 图书维护界面
* @return AnchorPane布局,便于其他控件调用
*/
public AnchorPane initBookManageFrame() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("view/bookManageFrame.fxml"));
try {
return loader.load();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 关于软件 弹出框界面
*/
public void initAboutSoftFrame() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("view/softInformationFrame.fxml"));
AnchorPane page = loader.load();
Stage mainFrameStage = new Stage();
mainFrameStage.setTitle("关于软件");
mainFrameStage.setResizable(true);
mainFrameStage.setAlwaysOnTop(false);
mainFrameStage.initModality(Modality.APPLICATION_MODAL);
mainFrameStage.initOwner(primaryStage);
Scene scene = new Scene(page);
mainFrameStage.setScene(scene);
SoftInformationFrameController controller = loader.getController();
controller.setDialogStage(mainFrameStage);
mainFrameStage.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
}