📄 regedit.java
字号:
//注册的界面
package com.yanjun;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class Regedit extends JFrame{
JLabel L1=new JLabel("新建用户名称");
JTextField txt=new JTextField(20);
JLabel L2=new JLabel("新建用户密码");
JPasswordField pass1 = new JPasswordField(20);
JLabel L3=new JLabel("确认用户密码");
JPasswordField pass2 = new JPasswordField(20);
String [] types={"学生","教师"};
JComboBox cb=new JComboBox();
JButton b1=new JButton("注册");
JButton b2=new JButton("取消");
ActionListener a1 = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String id=txt.getText();
String id1=pass1.getText();
String id2=pass2.getText();
int num=cb.getSelectedIndex();
if(id1.equals(id2))
{
if(num==0){
if(adduser.add1(id,id1))
JOptionPane.showMessageDialog(null,
"你已经注册成功", "提示信息",
JOptionPane.ERROR_MESSAGE);
else JOptionPane.showMessageDialog(null,
"你所要建立的用户已经存在", "提示错误信息",
JOptionPane.ERROR_MESSAGE);
}
if(num==1){if(adduser.add2(id,id1))
JOptionPane.showMessageDialog(null,
"你已经注册成功", "提示信息",
JOptionPane.ERROR_MESSAGE);
else JOptionPane.showMessageDialog(null,
"你所要建立的用户已经存在", "提示错误信息",
JOptionPane.ERROR_MESSAGE);
}
}
else JOptionPane.showMessageDialog(null,
"你输入的密码不符", "提示错误信息",
JOptionPane.ERROR_MESSAGE);
}
};
ActionListener a2 = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
}
};
public Regedit()
{
super("新建用户");
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
for(int i=0;i<types.length;i++)
cb.addItem(types[i]);
cp.add(L1);
cp.add(txt);
cp.add(L2);
cp.add(pass1);
cp.add(L3);
cp.add(pass2);
cp.add(cb);
cp.add(b1);
cp.add(b2);
b1.addActionListener(a1);
b2.addActionListener(a2);
setSize(350,150);
show();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -