📄 mainframe.java
字号:
package ui;
import AccountsPack.User;
import javax.swing.*;
public class MainFrame extends JFrame {
private static MainFrame _INSTANCE;
private JTabbedPane _tabPane = new JTabbedPane();
private User _currentUser = null;
MainFrame(){
super("Hotel");
_INSTANCE = this;
setContentPane(_tabPane);
pack();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocation(100,100);
setVisible(false);
}
public static MainFrame getMainFrame(){
return _INSTANCE;
}
public User getCurrentUser(){
return _currentUser;
}
public void setCurrentUser(User user){
_currentUser = user;
}
public boolean login(){
return true;
}
public boolean logout(){
_currentUser = null;
return true;
}
public void init(){
addPanes(_currentUser.get_identity());
this.setResizable(false);
this.setSize(640,400);
}
public void addPanes(int userIndentity){
if(userIndentity == User.GRP_CUSTOMER){
_tabPane.add("UserInfo", new UserPanel());
_tabPane.add("BookRoom", new BookPanel());
_tabPane.add("OrderList", new OrderList(userIndentity));
}
else if (userIndentity == User.GRP_OPERATOR){
_tabPane.add("UserInfo", new UserPanel());
_tabPane.add("BookRoom", new BookPanel());
_tabPane.add("RoomInfo", new RoomPanel());
_tabPane.add("RoomList", new RoomList());
}
else if (userIndentity == User.GRP_ADMINISTRATOR){
_tabPane.add("RoomInfo", new RoomPanel());
_tabPane.add("BookRoom", new BookPanel());
_tabPane.add("UserList", new UserList());
_tabPane.add("RoomList", new RoomList());
_tabPane.add("OrderList", new OrderList(userIndentity));
}else
{
System.err.println("User indentity err");
this.dispose();
}
setVisible(true);
}
public static void main(String []args){
new MainFrame();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -