📄 load.java
字号:
package mainface;
import java.awt.*;
import java.net.*;
import javax.swing.*;
import java.awt.event.*;
public class Load extends JFrame implements ActionListener{
Thread t;
JLabel label;
JFrame jframe=new JFrame("学生成绩管理系统登陆");
JButton button=new JButton("确定");
JButton button1=new JButton("取消");
JButton buttondial=new JButton("确定");
JTextField field=new JTextField();
JPasswordField word=new JPasswordField();
JDialog dialog=new JDialog();
protected static String name,pass;
public void makeFace(){
((JPanel)jframe.getContentPane()).setOpaque(false);
GridLayout grid=new GridLayout(3,0);
jframe.setLayout(grid);
JLabel jb=new JLabel(new ImageIcon(getClass().getResource("stu.jpg")));
jframe.getLayeredPane().add(jb,new Integer(Integer.MIN_VALUE));
jb.setBounds(0,0,1024,768);
label=new JLabel(new ImageIcon(getClass().getResource("biao.gif")));
JPanel panel=new JPanel();
JPanel panel1=new JPanel();
panel1.setOpaque(false);
panel.setOpaque(false);
panel1.setLayout(new GridLayout(0,3,35,3));
panel.setLayout(new GridLayout(8,4));
for(int i=1;i<=4;i++)
panel.add(new JLabel());
panel.add(new JLabel(" 用户名:"));
panel.add(field);
panel.add(new JLabel());
panel.add(new JLabel());
panel.add(new JLabel(" 密码:"));
panel.add(word);
panel1.add(button);
panel1.add(button1);
button.setDefaultCapable(true);
button.addActionListener(this);
button1.addActionListener(this);
panel1.add(new JLabel());
for(int j=1;j<=21;j++)
if(j==8)
panel.add(panel1);
else
panel.add(new JLabel());
// label.setAlignmentX(-100);
t=new Thread(new Runnable(){
public void run(){
int x=label.getX();
int y=x;
while(x<=750){
try{
t.sleep(25);
}catch(Exception a){
a.printStackTrace();
}
label.setBounds(x,label.getY(),label.getWidth(),label.getHeight());
x=x+5;
if(x==750){
x=y-750;
}
}
}
});
t.start();
jframe.add(label);
jframe.add(panel);
jframe.setVisible(true);
jframe.setBounds(0,0,1024,768);
jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public void notice(){//提示框信息;
JPanel panel=new JPanel();
dialog.setTitle("有点错误");
dialog.setBounds(550,200,300,200);
dialog.setLayout(new GridLayout(4,0,20,15));
dialog.add(new JLabel());
JLabel label=new JLabel(" @用户名或密码错误!");
panel.setLayout(new GridLayout(1,3,50,40));
panel.add(new JLabel());
panel.add(buttondial);
panel.add(new JLabel());
label.setFont(new Font("",Font.BOLD,20));
buttondial.addActionListener(this);
dialog.add(label);
dialog.add(panel);
dialog.setVisible(false);
}
public void Changeword(String s,String ss){
name=s;
pass=ss;
}
public boolean Checkid(){
String a=field.getText()+new String(word.getPassword());
return a.equals(name+pass);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==button)
if(Checkid())
{
Std_face.main(null);
jframe.setVisible(false);
}
else
dialog.setVisible(true);
if(e.getSource()==button1){
field.setText("");
word.setText("");
}
if(e.getSource()==buttondial){
dialog.setVisible(false);
}
}
public static void main(String args[]){
Load load= new Load();
load.Changeword("cai", "123");
load.notice();
load.makeFace();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -