用java学生信息管理系统 使用图形用户界面,用数据建立学生信息表,可以连接数据库,
2个回答
展开全部
呵呵
我正好在做这个,给你个用户登陆界面,希望采纳哈
package shixunxiangmu;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class LoginFrame {
private String username = "黄朋";
private int pwdstr = 111265;
public LoginFrame() {
JLabel jlCimg = new JLabel();
ImageIcon img = new ImageIcon("G:\\图片\\网页图标\\1.jpg");
jlCimg.setIcon(img);
final JFrame f = new JFrame();
Font font = new Font("楷体", Font.BOLD, 18);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setTitle("欢迎进入学籍管理登陆页面!");
f.setSize(360, 260);
f.setLayout(null);
f.setLocationRelativeTo(null);
JLabel l1 = new JLabel("用户名");
l1.setBounds(25, 20, 60, 35);
l1.setFont(font);
final JTextField tf1 = new JTextField();
tf1.setBounds(100, 23, 200, 30);
tf1.setFont(font);
JLabel l2 = new JLabel("密 码");
l2.setBounds(25, 70, 60, 35);
l2.setFont(font);
final JPasswordField pwd = new JPasswordField();
pwd.setBounds(100, 73, 200, 30);
pwd.setFont(font);
pwd.setEchoChar('*');
final JRadioButton rb1 = new JRadioButton("管理员");
rb1.setBounds(100, 113, 90, 30);
rb1.setFont(font);
rb1.setSelected(true);
final JRadioButton rb2 = new JRadioButton("用户");
rb2.setBounds(220, 113, 70, 30);
rb2.setFont(font);
ButtonGroup bg = new ButtonGroup();
bg.add(rb1);
bg.add(rb2);
final JButton bt2 = new JButton("退出");
bt2.setBounds(200, 163, 80, 30);
bt2.setFont(font);
bt2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bt2) {
System.exit(0);
}
}
});
JButton bt1 = new JButton("登录");
bt1.setBounds(100, 163, 80, 30);
bt1.setFont(font);
bt1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
String usernameinput = tf1.getText();
String pwdstrinput = String.valueOf(pwd.getPassword());
if ((usernameinput.equals(username))
&& (pwdstrinput.equals(pwdstrinput))) {
JOptionPane.showMessageDialog(null, "登陆成功!");
new Stmessege();
f.setVisible(false);
tf1.grabFocus();
pwd.grabFocus();
return;
} else if (pwdstrinput == null || "".equals(pwdstrinput)) {
JOptionPane.showMessageDialog(null, "密码不能为空");
pwd.grabFocus();
return;
} else if (pwdstrinput.length() < 6) {
JOptionPane.showMessageDialog(null, "密码不能小于6位");
pwd.grabFocus();
return;
} else {
JOptionPane.showMessageDialog(null, "登陆失败!");
}
if (rb1.isSelected());
}
});
f.add(jlCimg);
f.add(l1);
f.add(tf1);
f.add(l2);
f.add(pwd);
f.add(bt1);
f.add(bt2);
f.add(rb1);
f.add(rb2);
f.setVisible(true);
}
public static void main(String[] args) {
new LoginFrame();
}
}
我正好在做这个,给你个用户登陆界面,希望采纳哈
package shixunxiangmu;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class LoginFrame {
private String username = "黄朋";
private int pwdstr = 111265;
public LoginFrame() {
JLabel jlCimg = new JLabel();
ImageIcon img = new ImageIcon("G:\\图片\\网页图标\\1.jpg");
jlCimg.setIcon(img);
final JFrame f = new JFrame();
Font font = new Font("楷体", Font.BOLD, 18);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setTitle("欢迎进入学籍管理登陆页面!");
f.setSize(360, 260);
f.setLayout(null);
f.setLocationRelativeTo(null);
JLabel l1 = new JLabel("用户名");
l1.setBounds(25, 20, 60, 35);
l1.setFont(font);
final JTextField tf1 = new JTextField();
tf1.setBounds(100, 23, 200, 30);
tf1.setFont(font);
JLabel l2 = new JLabel("密 码");
l2.setBounds(25, 70, 60, 35);
l2.setFont(font);
final JPasswordField pwd = new JPasswordField();
pwd.setBounds(100, 73, 200, 30);
pwd.setFont(font);
pwd.setEchoChar('*');
final JRadioButton rb1 = new JRadioButton("管理员");
rb1.setBounds(100, 113, 90, 30);
rb1.setFont(font);
rb1.setSelected(true);
final JRadioButton rb2 = new JRadioButton("用户");
rb2.setBounds(220, 113, 70, 30);
rb2.setFont(font);
ButtonGroup bg = new ButtonGroup();
bg.add(rb1);
bg.add(rb2);
final JButton bt2 = new JButton("退出");
bt2.setBounds(200, 163, 80, 30);
bt2.setFont(font);
bt2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bt2) {
System.exit(0);
}
}
});
JButton bt1 = new JButton("登录");
bt1.setBounds(100, 163, 80, 30);
bt1.setFont(font);
bt1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
String usernameinput = tf1.getText();
String pwdstrinput = String.valueOf(pwd.getPassword());
if ((usernameinput.equals(username))
&& (pwdstrinput.equals(pwdstrinput))) {
JOptionPane.showMessageDialog(null, "登陆成功!");
new Stmessege();
f.setVisible(false);
tf1.grabFocus();
pwd.grabFocus();
return;
} else if (pwdstrinput == null || "".equals(pwdstrinput)) {
JOptionPane.showMessageDialog(null, "密码不能为空");
pwd.grabFocus();
return;
} else if (pwdstrinput.length() < 6) {
JOptionPane.showMessageDialog(null, "密码不能小于6位");
pwd.grabFocus();
return;
} else {
JOptionPane.showMessageDialog(null, "登陆失败!");
}
if (rb1.isSelected());
}
});
f.add(jlCimg);
f.add(l1);
f.add(tf1);
f.add(l2);
f.add(pwd);
f.add(bt1);
f.add(bt2);
f.add(rb1);
f.add(rb2);
f.setVisible(true);
}
public static void main(String[] args) {
new LoginFrame();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |