login.java
来自「用Java与MySQL开发的小型学生成绩管理系统」· Java 代码 · 共 60 行
JAVA
60 行
package chuangti;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class login extends JFrame {
public login()
{
JLabel title=new JLabel("学生成绩管理系统");
JButton studentlogins=new JButton("学生登录");
Font l=new Font("SansSerif",Font.BOLD,20);
Font f=new Font("SansSerif",Font.BOLD,66);
setLayout(new GridLayout(2,1));
title.setFont(f);
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setVerticalAlignment(SwingConstants.CENTER);
title.setSize(100,100);
studentlogins.setFont(l);
studentlogins.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
studentlogin studentloginframe=new studentlogin();
studentloginframe.setVisible(true);
studentloginframe.setSize(300,200);
studentloginframe.setTitle("学生登录");
studentloginframe.setLocation(300,250);
}
});
JButton teacherlogin=new JButton("教师登录");
teacherlogin.setFont(l);
add(title);
teacherlogin.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
teacherlogin a=new teacherlogin();
teacherlogin teacherloginframe=new teacherlogin();
teacherloginframe.setVisible(true);
teacherloginframe.setSize(300,200);
teacherloginframe.setTitle("教师登录");
teacherloginframe.setLocation(300, 250);
}
});
JPanel botton=new JPanel();
botton.setLayout(new FlowLayout(FlowLayout.CENTER,30,30));
botton.add(studentlogins);
botton.add(teacherlogin);
add(botton);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
login begin=new login();
begin.setVisible(true);
begin.setSize(900,600);
begin.setTitle("学生成绩管理系统");
begin.setExtendedState(MAXIMIZED_BOTH);
begin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?