当前位置:文档之家› java学生信息管理系统界面代码

java学生信息管理系统界面代码

package edu.gzu.stuManager;import java.awt.Color;import java.awt.Container;import java.awt.Cursor;import java.awt.Font;import java.awt.Image;import java.awt.event.ActionEvent; import java.awt.event.ActionListener;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComboBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JRootPane;import javax.swing.JTextField;public class StudentMainView extends JFrame{private static final long serialVersionUID = -6788045638380819221L;//用户名private JTextField ulName;//密码private JPasswordField ulPasswd;//小容器private JLabel j1;private JLabel j2;private JLabel j3;private JLabel j4;private JLabel j5;private JLabel j6;//小按钮private JButton b1;private JButton b2;//复选框private JCheckBox c1;private JCheckBox c2;//列表框private JComboBox<String> cb1;/*** 初始化QQ登录页面* */public StudentMainView (){//设置登录窗口标题this.setTitle("学生信息管理系统");//去掉窗口的装饰(边框)// this.setUndecorated(true);//采用指定的窗口装饰风格this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);//窗体组件初始化init();this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );//设置布局为绝对定位*******this.setLayout(null);this.setBounds(100, 100, 1055, 765);//设置窗体的图标Image img0= new ImageIcon("F:/1.jpg").getImage(); this.setIconImage(img0);//窗体大小不能改变this.setResizable(false);//居中显示this.setLocationRelativeTo(null);//窗体显示this.setVisible(true);}/*** 窗体组件初始化* */public void init(){Container container = this.getContentPane();j1 = new JLabel();//设置背景图片Image img1 = newImageIcon("C:\\Users\\hasee\\Desktop\\123\\2.jpg") .getImage();j1.setIcon(new ImageIcon(img1));j1.setBounds(0,0, 1055, 765);//LOGE设定j2 = new JLabel();Image img2 = newImageIcon("D:/hdimg.png").getImage();j2.setIcon(new ImageIcon(img2));j2.setBounds(40, 95, 50, 53);//用户名输入框//注册账号j3 = new JLabel("用户名");ulName = new JTextField();ulName.setBounds(450, 200, 200, 35);//注册账号j3 = new JLabel("用户名:");j3.setFont(new Font("宋体", Font.PLAIN, 25)); j3.setBounds(330, 162, 100, 120);//密码输入框ulPasswd = new JPasswordField();ulPasswd.setBounds(450, 250, 200, 35);//找回密码j4= new JLabel("密码:");j4.setSize(12, 45);j4.setFont(new Font("宋体", Font.PLAIN, 25)); j4.setBounds(330, 206, 100, 120);j5= new JLabel("欢迎登陆学生信息管理系统!");j5.setSize(500, 100);j5.setFont(new Font("宋体", Font.PLAIN, 50)); j5.setBounds(220, 0, 1000, 220);j6= new JLabel("我的身份是:");j6.setSize(50, 100);j6.setFont(new Font("宋体", Font.PLAIN, 25)); j6.setBounds(330, 210, 500, 220);//记住密码c1 = new JCheckBox("记住密码");c1.setBounds(330, 450, 150, 40);//自动登陆c2 = new JCheckBox("自动登陆");c2.setBounds(500, 450, 150, 40);//用户登陆状态选择cb1 = new JComboBox<String>();cb1.addItem("学生");cb1.addItem("老师");cb1.addItem("管理员");cb1.setBounds(550, 300, 100, 40);//登陆按钮b1 = new JButton("登录");//设置字体和颜色和手形指针b1.setFont(new Font("宋体", Font.PLAIN, 15));b1.setForeground(Color.RED);b1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));b1.setBounds(330, 370, 100, 40);//给按钮添加b1.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand();if("登录".equals(cmd)){String username = ulName.getText();@SuppressWarnings("deprecation")String userpassword = ulPasswd.getText();if(username.equals("2019") && userpassword.equals("2019")){JOptionPane.showConfirmDialog(null, "登录成功");}else{JOptionPane.showConfirmDialog(null, "登录失败");}}}});//多账号b2 = new JButton("取消");b2.setFont(new Font("宋体", Font.PLAIN, 15));b2.setForeground(Color.RED);b2.setCursor(Cursor.getPredefinedCursor(Cursor.HAN D_CURSOR));b2.setBounds(550, 370, 100, 40);//所有组件用容器装载j1.add(j2);j1.add(j3);j1.add(j4);j1.add(j5);j1.add(j6);j1.add(c1);j1.add(c2);j1.add(cb1);j1.add(b1);j1.add(b2);container.add(j1);container.add(ulName);container.add(ulPasswd);}public static void main(String[] args) { new StudentMainView();}}。

相关主题