您的位置:首页 > 其它

仿"广东省2013年普通高校招生志愿填报系统"登录界面

2013-06-28 22:02 471 查看
package gditc.student.gaokao;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
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 java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
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 javax.swing.UIManager;

import gditc.cryhelyxx.LinkLabel;

public class Gaokao extends JFrame implements  MouseMotionListener, MouseListener, ActionListener {

/**
*
*/
private static final long serialVersionUID = 1L;
private static final int WIDTH = 775;
private static final int HEIGHT = 590;

private JLabel lblImage;
private JLabel lblWord1;
private JLabel lblWord2;
private JLabel lblWord3;
private JLabel lblWord4;
private JLabel lblWord5;
private JLabel lblWord6;
private JLabel lblCoryright;

private JLabel lblNum;
private JLabel lblPwd;
private JLabel lblPwdProve;

private JTextField txtNum;
private JPasswordField txtPwd;
private JTextField txtPwdProve;

private JButton btnConform;
private JButton btnCancel;

private JPanel jpGaokao;
private JPanel jpInfo;

private JButton btnClose;
private JButton btnMini;
private JButton btnSkin;

int mx;
int my;
private boolean isDraging = false;

public Gaokao(){
super();
Init();
}

private void Init() {
this.setTitle("广东省2013年普通高校招生志愿填报系统");
this.setUndecorated(true);	//不使用窗体装饰
this.setSize(WIDTH, HEIGHT);
this.setLocationRelativeTo(null);	//窗体出现在屏幕相对居中位置
this.setIconImage(new ImageIcon(this.getClass().getResource("images/haha.png")).getImage());
this.setResizable(false);	//禁止调整窗体大小
this.addMouseListener(this);
this.setVisible(true);
this.addMouseMotionListener(this);

lblImage = new JLabel(new ImageIcon(this.getClass().getResource("images/haha.png")));
lblImage.setBounds(19, 59, 84, 86);

lblWord1 = new JLabel("广东省2013年普通高校招生志愿填报系统");
lblWord1.setFont(new Font("楷体", Font.BOLD, 25));
lblWord1.setForeground(new Color(255, 255, 255));
lblWord1.setBounds(168, 80, 480, 50);

lblWord2 = new JLabel("考生用户登录");
lblWord2.setFont(new Font("宋体", Font.PLAIN, 18));
lblWord2.setForeground(new Color(255, 255, 255));
lblWord2.setBounds(133, -10, 480, 50);

lblWord3 = new JLabel("5699");
lblWord3.setFont(new Font("Brush Script MT", Font.PLAIN, 18));
lblWord3.setForeground(new Color(255, 255, 255));
lblWord3.setBounds(293, 96, 480, 50);

lblWord4 = new LinkLabel("操作说明", "http://www.ecogd.edu.cn/kszy/sys/shouce.htm");
lblWord4.setFont(new Font("宋体", Font.PLAIN, 18));
lblWord4.setForeground(new Color(255, 255, 255));
lblWord4.setBounds(350, 368, 80, 50);

lblWord5 = new JLabel("版权所有©广东省教育考试院");
lblWord5.setFont(new Font("宋体", Font.BOLD, 14));
lblWord5.setBounds(295, 495, 480, 50);

lblWord6 = new JLabel("Coryright©2008-2013");
lblWord6.setFont(new Font("宋体", Font.BOLD, 12));
lblWord6.setBounds(327, 527, 480, 50);

lblCoryright = new JLabel("Designed by Cryhelyxx");
lblCoryright.setFont(new Font("华文行楷", Font.BOLD, 16));
lblCoryright.setForeground(new Color(255, 0, 0));
lblCoryright.setBounds(605, 550, 480, 50);

lblNum = new JLabel("考生号:");
lblNum.setFont(new Font("宋体", Font.PLAIN, 12));
lblNum.setBounds(56, 40, 60, 18);

lblPwd = new JLabel("密  码:");
lblPwd.setFont(new Font("宋体", Font.PLAIN, 12));
lblPwd.setBounds(56, 72, 60, 24);

lblPwdProve = new JLabel("验证码:");
lblPwdProve.setFont(new Font("宋体", Font.PLAIN, 12));
lblPwdProve.setBounds(56, 104, 60, 18);

txtNum = new JTextField();
txtNum.setBounds(116, 41, 148, 25);

txtPwd = new JPasswordField();
txtPwd.setBounds(116, 74, 157, 25);

txtPwdProve = new JTextField();
txtPwdProve.setBounds(116, 107, 148, 25);

btnConform = new JButton("确定");
btnConform.setFont(new Font("宋体", Font.PLAIN, 12));
btnConform.setBounds(119, 149, 52, 27);
btnConform.addActionListener(this);

btnCancel = new JButton("取消");
btnCancel.setFont(new Font("宋体", Font.PLAIN, 12));
btnCancel.setBounds(206, 149, 52, 27);
btnCancel.addActionListener(this);

final ImageIcon buttonClose1 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_close_normal.png"));
final ImageIcon buttonClose2 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_close_highlight.png"));
final ImageIcon buttonClose3 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_close_down.png"));
btnClose = new JButton(buttonClose1);
btnClose.setBounds(735, -12, 42, 40);
btnClose.setBorder(null);
btnClose.setContentAreaFilled(false);	//按钮设置为透明,这样就不会挡着后面的背景
btnClose.addActionListener(this);
btnClose.addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {
btnClose.setIcon(buttonClose3);
}

public void mouseEntered(MouseEvent e) {
btnClose.setIcon(buttonClose2);

}

public void mouseExited(MouseEvent e) {
btnClose.setIcon(buttonClose1);

}
});

final ImageIcon buttonMini1 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_mini_normal.png"));
final ImageIcon buttonMini2 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_mini_highlight.png"));
final ImageIcon buttonMini3 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_mini_down.png"));
btnMini = new JButton(buttonMini1);
btnMini.setBounds(703, -12, 42, 40);
btnMini.setBorder(null);
btnMini.setContentAreaFilled(false);	//按钮设置为透明,这样就不会挡着后面的背景
btnMini.addActionListener(this);
btnMini.addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {
btnMini.setIcon(buttonMini3);
}

public void mouseEntered(MouseEvent e) {
btnMini.setIcon(buttonMini2);

}

public void mouseExited(MouseEvent e) {
btnMini.setIcon(buttonMini1);

}
});

final ImageIcon buttonSkin1 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_Skin_normal.png"));
final ImageIcon buttonSkin2 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_Skin_highlight.png"));
final ImageIcon buttonSkin3 = new ImageIcon(	//一定要用final
this.getClass().getResource("images/btn_Skin_down.png"));
btnSkin = new JButton(buttonSkin1);
btnSkin.setBounds(677, -12, 42, 40);
btnSkin.setBorder(null);
btnSkin.setContentAreaFilled(false);	//按钮设置为透明,这样就不会挡着后面的背景
btnSkin.addActionListener(this);
btnSkin.addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {
btnSkin.setIcon(buttonSkin3);
}

public void mouseEntered(MouseEvent e) {
btnSkin.setIcon(buttonSkin2);

}

public void mouseExited(MouseEvent e) {
btnSkin.setIcon(buttonSkin1);

}
});

jpGaokao = new JPanel();
jpGaokao.setLayout(null);
jpGaokao.setVisible(true);
jpGaokao.setBackground(new Color(10, 69, 205));
jpGaokao.setBounds(0, 0, WIDTH, HEIGHT);

jpInfo = new JPanel();
jpInfo.setLayout(null);
jpInfo.setVisible(true);
jpInfo.setBackground(new Color(109, 145, 233));
jpInfo.setBounds(207, 173, 365, 179);

jpInfo.add(lblWord2);
jpInfo.add(lblWord3);
jpInfo.add(lblNum);
jpInfo.add(lblPwd);
jpInfo.add(lblPwdProve);
jpInfo.add(txtNum);
jpInfo.add(txtPwd);
jpInfo.add(txtPwdProve);
jpInfo.add(btnConform);
jpInfo.add(btnCancel);

jpGaokao.add(lblImage);
jpGaokao.add(lblWord1);
jpGaokao.add(lblWord4);
jpGaokao.add(lblWord5);
jpGaokao.add(lblWord6);
jpGaokao.add(lblCoryright);
jpGaokao.add(jpInfo);
jpGaokao.add(btnClose);
jpGaokao.add(btnMini);
jpGaokao.add(btnSkin);

this.setContentPane(jpGaokao);
//this.add(jpGaokao);	//跟上一句同效果

}

@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mousePressed(MouseEvent e) {
isDraging = true;
mx = e.getX();
my = e.getY();
}

@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseDragged(MouseEvent e) {
if (isDraging) {
int x = getLocation().x;
int y = getLocation().y;

x = x + e.getX() - mx;
y = y + e.getY() - my;
setLocation(x, y);
}
}

@Override
public void mouseMoved(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == btnClose){
System.exit(0);
}
if(e.getSource() == btnMini){
this.setExtendedState(JFrame.ICONIFIED);   //设置当前窗体的状态为最小化
}
if(e.getSource() == btnSkin){
JOptionPane.showMessageDialog(null, "Sorry,换肤功能暂时不可用!");
}
if(e.getSource() == btnConform){
if(txtNum.getText().trim().equals("")){//判断该字符串是否为空
JOptionPane.showMessageDialog(null, "考生号不能为空!", "友情提示", JOptionPane.ERROR_MESSAGE);
txtNum.setText("");
}
else if(txtPwd.getPassword().equals("")){//判断该字符串是否为空
JOptionPane.showMessageDialog(null, "密码不能为空!", "友情提示", JOptionPane.ERROR_MESSAGE);
txtPwd.setText("");
}
else if(txtPwdProve.getText().trim().equals("")){//判断该字符串是否为空
JOptionPane.showMessageDialog(null, "验证码不能为空!", "友情提示", JOptionPane.ERROR_MESSAGE);
txtPwdProve.setText("");
}
else if(!txtPwdProve.getText().trim().equals("5699")){//判断该字符串是否为空
JOptionPane.showMessageDialog(null, "验证码错误!", "友情提示", JOptionPane.ERROR_MESSAGE);
txtPwdProve.setText("");
}
else
JOptionPane.showMessageDialog(null, "系统尚未开放!");
}
if(e.getSource() == btnCancel){
System.exit(0);
}
}

public static void main(String[] args){
try{
//改变SWING外观
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");	//Windows风格
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch(Exception e){
e.printStackTrace();
}
new Gaokao();
}

}
/**
* 本人将下面的类生成了Link.jar,所以有句"import gditc.cryhelyxx.LinkLabel;"
*/
/*class LinkLabel extends JLabel {
*//**
*
*//*
private static final long serialVersionUID = 1L;
private String text, url;
private boolean isSupported;

public LinkLabel(String text, String url) {
this.text = text;
this.url = url;

try {
this.isSupported = Desktop.isDesktopSupported()
&& Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);
} catch (Exception e) {
this.isSupported = false;
}

setText(false);

addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
setText(isSupported);
if (isSupported)
setCursor(new Cursor(Cursor.HAND_CURSOR));
}

public void mouseExited(MouseEvent e) {
setText(false);
}

public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(
new java.net.URI(LinkLabel.this.url));
} catch (Exception ex) {
}
}
});
}

private void setText(boolean b) {
if (!b)
setText("<html><font color=white><u>" + text);
else
setText("<html><font color=red><u>" + text);
}
}
*/

运行结果如下:



参照:http://www.ecogd.edu.cn/kszy/login.jsp

以上纯属个人娱乐,没什么技术含量。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐