import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
public class QQ2012 extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private JLabel l1,l2,l0,l3;
private JButton btn1,btn2,btn3;
private JCheckBox chb1,chb2;
private JComboBox jcb,jcb1;
private JPasswordField jpf;
JFrame jf;
CInstead c1=new CInstead();
Container c;
QQ2012(){
setTitle("QQ2012");
setContentPane(c1);
c = getContentPane();
//Icon i1 = new ImageIcon("qq.jpg");
ImageIcon image=new ImageIcon("src\images\qq.jpg");
ImageIcon image1=new ImageIcon("src\images\33.jpg");
//image.setImage(image.getImage().getScaledInstance(100,105,Image.SCALE_DEFAULT ));
jf = new JFrame("QQ2012");
//l0 = new JLabel(image1);
//l0.setFont(new Font("华文行楷",Font.BOLD,36));
//Color linkColor = new Color(49, 89, 151);
l1 = new JLabel("注册账号");
l1.setToolTipText("申请账号");
l2 = new JLabel("找回密码");
l3 = new JLabel(image);
chb1 = new JCheckBox("记住密码");
chb2 = new JCheckBox("自动登陆");
jpf = new JPasswordField();
jcb = new JComboBox();
jcb1 = new JComboBox();
jcb1.addItem("隐身");
jcb1.addItem("我在线上");
jcb1.addItem("Q我吧");
btn1 = new JButton("多账号");
btn2 = new JButton("设置");
btn3 = new JButton("登陆");
//绝对定位
//l0.setBounds(0,0,340,80);
jcb.setBounds(100,90,140,30);
l1.setBounds(255,95,70,20);
l1.setFont(new Font(" 宋体",0,17));
l1.setForeground(new Color(0,0,210));
jpf.setBounds(100,130,140,30);
l2.setBounds(255,133,70,20);
l2.setFont(new Font("宋体",0,17));
l2.setForeground(new Color(0,0,210));
jcb1.setBounds(100,170,60,20);
jcb1.setFont(new Font("宋体",0,13));
l3.setBounds(5,90,90,100);
chb1.setBounds(160,170,85,20);
chb1.setFont(new Font("宋体",0,14));
chb2.setBounds(245,170,85,20);
chb2.setFont(new Font("宋体",0,14));
btn1.setBounds(10,210,80,25);
btn1.setFont(new Font("宋体",0,14));
btn2.setBounds(110,210,80,25);
btn2.setFont(new Font("宋体",0,14));
btn3.setBounds(245,210,80,25);
btn3.setFont(new Font("宋体",0,14));
//添加控件
c.setLayout(null);
c.add(l3);
//c.add(l0);
c.add(l1);
c.add(l2);
c.add(jcb);
c.add(jpf);
c.add(jcb1);
c.add(chb1);
c.add(chb2);
c.add(btn1);
c.add(btn2);
c.add(btn3);
jcb.setEditable(true);
setVisible(true);
setBounds(420,170,350,280);
//this.setResizable(false);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
l1.setCursor(new Cursor(Cursor.HAND_CURSOR));//这样也可以改变鼠标形状
l1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent mouseEvent) {
String bd = "http://zc.qq.com/chs/index.html?from=client";
try {
//Runtime.getRuntime().exec( "C:\Program Files\Internet Explorer\IEXPLORE.EXE "+picurl); //这种方式也可以,不过有时候是打不开图的 ,第二种方式没问题
Runtime.getRuntime().exec("cmd.exe /c start "+bd);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
l2.setCursor(new Cursor(Cursor.HAND_CURSOR));//这样也可以改变鼠标形状
l2.setToolTipText("找回密码");
l2.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent mouseEvent) {
String bd = "http://aq.qq.com/cn2/findpsw/findpsw_index?source_id=1003&ptlang=2052&aquin=948873368";
try {
//Runtime.getRuntime().exec( "C:\Program Files\Internet Explorer\IEXPLORE.EXE "+picurl); //这种方式也可以,不过有时候是打不开图的 ,第二种方式没问题
Runtime.getRuntime().exec("cmd.exe /c start "+bd);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
public static void main(String[] args){
new QQ2012();
}
@SuppressWarnings("deprecation")
@Override
public void actionPerformed(ActionEvent e) { //按钮事件监听
// TODO Auto-generated method stub
if(e.getSource().equals(btn3))
if(jcb.getEditor().equals("995703887") && jpf.getText().equals("java") )
JOptionPane.showMessageDialog(jf,
"登录成功");
else
JOptionPane.showMessageDialog(jf,
"登录失败");
}
//添加背景图片
class CInstead extends JPanel //继承JPanel
{
/**
*
*/
private static final long serialVersionUID = 8816454708132049722L;
//ImageIcon icon;
Image img;
public CInstead()
{
//icon=new ImageIcon(LL.class.getResource("src\images\087.jpg" ));
//img=icon.getImage();
img=Toolkit.getDefaultToolkit().getImage("src\images\087.jpg"); //获取图片
}
public void paintComponent(Graphics g)
{
super.paintComponent(g); //重载paintComponent方法
g.drawImage(img,0,0,null ); //绘制图片
}
}
}