java学生管理系统登录注册_《Java》— 学生管理系统——登录界面
學生管理系統登錄界面
package javaapplication10;
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 XSGL 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 JButton b1;
private JButton b2;
private JButton b3;
//復選框
private JCheckBox c1;
private JCheckBox c2;
//列表框
private JComboBoxcb1;
/**
* 初始化QQ登錄頁面
* */
public XSGL (){
//設置登錄窗口標題
this.setTitle("學生選課系統");
//去掉窗口的裝飾(邊框)
//this.setUndecorated(true);
//采用指定的窗口裝飾風格
this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
//窗體組件初始化
init();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//設置布局為絕對定位
this.setLayout(null);
this.setBounds(0, 0, 355, 265);
//設置窗體的圖標
Image img0 = new ImageIcon("F:/1.jpg").getImage();
this.setIconImage(img0);
//窗體大小不能改變
this.setResizable(false);
//居中顯示
this.setLocationRelativeTo(null);
//窗體顯示
this.setVisible(true);
}
/**
* 窗體組件初始化
* */
public void init(){
//創建一個容器,其中的圖片大小和setBounds第三、四個參數要基本一致(需要自己計算裁剪)
Container container = this.getContentPane();
j1 = new JLabel();
//設置背景圖片
Image img1 = new ImageIcon("F:/2.jpg").getImage();
j1.setIcon(new ImageIcon(img1));
j1.setBounds(0, 0, 355, 265);
//LOGE設定
j2 = new JLabel();
Image img2 = new ImageIcon("D:/hdimg.png").getImage();
j2.setIcon(new ImageIcon(img2));
j2.setBounds(40, 95, 50, 53);
//用戶名輸入框//注冊賬號
j3 = new JLabel("用戶名");
ulName = new JTextField();
ulName.setBounds(100, 100, 150, 20);
//注冊賬號
j3 = new JLabel("用戶名");
j3.setBounds(260, 100, 70, 20);
//密碼輸入框
ulPasswd = new JPasswordField();
ulPasswd.setBounds(100, 130, 150, 20);
//找回密碼
j4= new JLabel("密碼");
j4.setBounds(260, 130, 70, 20);
//記住密碼
c1 = new JCheckBox("記住密碼");
c1.setBounds(105, 155, 80, 15);
//自動登陸
c2 = new JCheckBox("自動登陸");
c2.setBounds(185, 155, 80, 15);
//用戶登陸狀態選擇
cb1 = new JComboBox();
cb1.addItem("學生");
cb1.addItem("老師");
cb1.addItem("管理");
cb1.setBounds(40, 150, 55, 20);
//登陸按鈕
b1 = new JButton("登錄");
//設置字體和顏色和手形指針
b1.setFont(new Font("宋體", Font.PLAIN, 12));
b1.setForeground(Color.RED);
b1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
b1.setBounds(280, 200, 65, 20);
//給按鈕添加
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if("登錄".equals(cmd)){
String username = ulName.getText();
String userpassword = ulPasswd.getText();
if(username.equals("20155104009") && userpassword.equals("20155104009")){
JOptionPane.showConfirmDialog(null, "登錄成功");
}else{
JOptionPane.showConfirmDialog(null, "登錄失敗");
}
}
}
});
//多賬號
b2 = new JButton("注冊");
b2.setBounds(5, 200, 75, 20);
//設置
b3 = new JButton("設置");
b3.setBounds(100, 200, 65, 20);
//所有組件用容器裝載
j1.add(j2);
j1.add(j3);
j1.add(j4);
j1.add(c1);
j1.add(c2);
j1.add(cb1);
j1.add(b1);
j1.add(b2);
j1.add(b3);
container.add(j1);
container.add(ulName);
container.add(ulPasswd);
}
public static void main(String[] args) {
new XSGL();
}
}
總結
以上是生活随笔為你收集整理的java学生管理系统登录注册_《Java》— 学生管理系统——登录界面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: git 放弃本地修改,强制拉取更新
- 下一篇: Java实现学生管理系统代码