好久没打开了,中文都乱码了,怎么把他们还原啊。。。别告诉我是手打、。
package com.hy.CrFrame;
import java.awt.Button;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import com.hy.util.DBHelper;
public class LoginFrame extends JFrame{
JLabel Administor;
JLabel password;
JLabel Identity;
Button submit;
Button reset;
JTextField Admin;
JPasswordField pass;
JComboBox Iden;
public LoginFrame(){
super();
setTitle("\u7CFB\u7EDF\u767B\u5F55"); //UTF-8����test
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel contentPane=new JPanel();
setContentPane(contentPane);
contentPane.setLayout(new BoxLayout(contentPane,BoxLayout.PAGE_AXIS));
Font fontStyle1=new Font("���ź�",Font.PLAIN,30);//����������ʽ1
/*
* ����һ����panel������һ��Panel
*/
JPanel blockJPanel1 = new JPanel();
blockJPanel1.setSize(200,100);
contentPane.add(blockJPanel1);
/*
* �û���ݱ�
* */
JPanel idenJPanel = new JPanel();
Identity=new JLabel("�û����");
Identity.setFont(fontStyle1);
idenJPanel.add(Identity);
Iden=new JComboBox();
Iden.setPreferredSize(new Dimension(286, 40));
Iden.addItem("ѧ��");
Iden.addItem("����Ա");
Iden.setFont(fontStyle1);
idenJPanel.add(Iden);
contentPane.add(idenJPanel);
/*
* �û�����
*/
JPanel adminiJPanel = new JPanel();
Administor=new JLabel("�� �� ��");
Administor.setFont(fontStyle1);
adminiJPanel.add(Administor);
Admin = new JTextField();
Admin.setColumns(10);
Admin.setFont(fontStyle1);
adminiJPanel.add(Admin);
contentPane.add(adminiJPanel);
/*
* �����
*/
JPanel passJPanel = new JPanel();
password = new JLabel("�� ��");
password.setFont(fontStyle1);
passJPanel.add(password);
pass =new JPasswordField();
pass.setColumns(10);
pass.setFont(fontStyle1);
passJPanel.add(pass);
contentPane.add(passJPanel);
/*
* ��ť����
*/
JPanel buttonJPanel = new JPanel();
buttonJPanel.setLayout(new FlowLayout(FlowLayout.CENTER,100,0));
submit = new Button("��¼");
submit.setFont(fontStyle1);
buttonJPanel.add(submit);
reset=new Button("����");
reset.setFont(fontStyle1);
buttonJPanel.add(reset);
contentPane.add(buttonJPanel);
/*
* ���ð�ť����
*/
submit.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
do_submitButton_actionPerformed(e);
}
});
reset.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
do_resetButton_actionPerformed(e);
}
});
pack();
setSize(800, 360);
this.setResizable(false);
//setBounds(800,400,800,600);
setLocation(com.hy.util.SwingUtil.centerContainer(getSize()));//���ô�����Ļ����
setVisible(true);
}
protected void do_resetButton_actionPerformed(ActionEvent e) {
Admin.setText("");
pass.setText("");
}
protected void do_submitButton_actionPerformed(ActionEvent e) {
String username=Admin.getText().trim();
char [] password_number=pass.getPassword();
String identity_item=Iden.getSelectedItem().toString();//��õ�ǰ�����˵�ѡ����
/*
* �ж��û����������Ƿ�Ϊ��
*/
if(username.isEmpty()){
JOptionPane.showMessageDialog(this, "�û�������Ϊ��","������Ϣ",JOptionPane.WARNING_MESSAGE);
return;
}
if(new String(password_number).isEmpty()){
JOptionPane.showMessageDialog(this, "���벻��Ϊ��","������Ϣ",JOptionPane.WARNING_MESSAGE);
return;
}
/*
* �ж�������Ϣ�Ƿ���ȷ
* */
if(identity_item.equals("����Ա")){//��ѡ�����Ա
if(!DBHelper.admin_exists(username)){
JOptionPane.showMessageDialog(this, "����Ա������","������Ϣ",JOptionPane.WARNING_MESSAGE);
return;
}
if(!DBHelper.admin_Check(username, password_number)){
JOptionPane.showMessageDialog(this, "�������","������Ϣ",JOptionPane.WARNING_MESSAGE);
return;
}
this.dispose();
new Admin_Frame();
}else{//��ѡ��ѧ����
/*
* �ж�ѧ����½��Ϣ�Ƿ���ȷ
* */
if(!DBHelper.student_exists(username)){
JOptionPane.showMessageDialog(this, "ѧ�Ų�����","������Ϣ",JOptionPane.WARNING_MESSAGE);
return;
}
if(!(new String(password_number).equals(username))){
JOptionPane.showMessageDialog(this, "�������","������Ϣ",JOptionPane.WARNING_MESSAGE);
return;
}
this.dispose();
new StudentFrame();
}
}
}
|
|