📄 guestframe.java
字号:
import java.sql.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class GuestFrame{
JFrame mainframe;
String current_usertype="";
String current_username="";
public GuestFrame(String username){
//当前用户的名字、类型
current_username=username;
//current_usertype=usertype;
//System.out.println(usertype);
//根据用户的类型创建的不同的主界面
mainframe=new JFrame("LoginDemo");
Container contentPane=mainframe.getContentPane();
JPanel buttonPanel=new JPanel();
//菜单设置
JMenuBar menu_bar=new JMenuBar();
menu_bar.setOpaque(true);
//菜单项-系统设置
JMenu sysconfig=new JMenu("系统设置");
JMenuItem password_modify=new JMenuItem("修改密码");
JMenuItem login_off=new JMenuItem("注销登录");
JMenuItem system_exit=new JMenuItem("退出");
sysconfig.add(password_modify);
sysconfig.add(login_off);
sysconfig.add(system_exit);
//菜单项-班级管理
JMenu classmanager=new JMenu("班级管理");
JMenuItem colligate_info=new JMenuItem("综合测评");
classmanager.add(colligate_info);
//菜单项-信息查询
JMenu info_lookup=new JMenu("信息查询");
JMenuItem individual_info=new JMenuItem("各科成绩");
JMenuItem colligate_query=new JMenuItem("综合测评");
JMenuItem scholarship_query=new JMenuItem("奖学金");
info_lookup.add(individual_info);
info_lookup.add(colligate_query);
info_lookup.add(scholarship_query);
//菜单项-帮助
JMenu help_menu=new JMenu("帮助");
JMenuItem about_menuitem=new JMenuItem("关于");
help_menu.add(about_menuitem);
menu_bar.add(sysconfig);
menu_bar.add(classmanager);
menu_bar.add(info_lookup);
menu_bar.add(help_menu);
mainframe.setJMenuBar(menu_bar);
//菜单项单击事件的响应
password_modify.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//修改密码
new PasswordModify(current_username);
}
});
login_off.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//注销登录
mainframe.dispose();
new Login();
}
});
system_exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//退出
System.exit(1);
}
});
colligate_info.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//综合测评
new ColligateInfo();
}
});
individual_info.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//学生信息
new StudentQuery();
}
});
colligate_query.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//综合测评
new ColligateQuery();
}
});
scholarship_query.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//奖学金
new ScholarshipQuery();
}
});
about_menuitem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//关于
JOptionPane.showMessageDialog(mainframe,"版权所有——王成茁、丁磊、徐英英、钟英旭、金峰、朱盛灿","关于",JOptionPane.WARNING_MESSAGE);
}
});
mainframe.pack();
mainframe.setVisible(true);
mainframe.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
//添加背景图片
JLabel welcome_label=new JLabel("网络工程061班——综合测评管理系统");
welcome_label.setFont(new java.awt.Font("宋体",1,24));
JPanel image_panel=new JPanel();
ImageIcon image=new ImageIcon("test.jpg");
JLabel image_label=new JLabel();
image_label.setIcon(image);
image_label.setBounds(new Rectangle(0,0,200,200));
image_panel.add(image_label);
mainframe.add("Center",image_panel);
mainframe.add("North",welcome_label);
Toolkit kit=Toolkit.getDefaultToolkit();
Dimension screenSize=kit.getScreenSize();
int width=screenSize.width;
int height=screenSize.height;
mainframe.setLocation((width-600)/2,(height-400)/2);
mainframe.setSize(600,400);
mainframe.setResizable(false);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -