七、實現步驟
(九)創建應用程序類
創建應用程序類,存在全局數據,所有的窗口界面都可以共享應用程序類裏存放的數據。
1、在net.hw.student包裏創建app子包
2、在net.hw.student.app包裏創建Application類
package net.hw.student.app;
/**
* 功能:應用程序類,存放全局數據
* 作者:華衛
* 日期:2020年06月06日
*/
public class Application {
public static int id; // 登錄用戶標識符
public static String username; // 登錄用戶名
public static String password; // 登錄用戶密碼
public static LoginFrame loginFrame; // 登錄窗口
public static MainFrame mainFrame; // 主窗口
public static RegisterFrame registerFrame; // 註冊窗口
}
- 此時,三個窗口界面類還未創建,因此程序會報錯:無法解析符號。
- 創建net.hw.student.gui包,在裏面創建三個類LoginFrame、RegisterFrame和MainFrame
- 查看應用程序類