JAVA高级程序设计

---恢复内容开始---

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;

public class DengLu {

public static void main(String[]args){
    final JFrame frm=new JFrame("系统登录");
    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    


    JPanel soPanel = new JPanel();
    
    frm.add(soPanel,BorderLayout.NORTH);

    JPanel topPanel = new JPanel();
    frm.add(topPanel,BorderLayout.EAST );
    //图
    Icon t3 = new ImageIcon("1191333.gif");
    JLabel l71 = new JLabel(t3); 
    l71.setBounds(0,0,t3.getIconWidth(),t3.getIconHeight());       
    soPanel.add(l71);
    
    
    JPanel wp = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JPanel iwp = new JPanel();
    wp.add(iwp);
    iwp.setLayout(new GridLayout(4, 1));
    JPanel p1 = new JPanel();
    JPanel p2 = new JPanel();
    JPanel p3 = new JPanel();
    JPanel p4 = new JPanel();
    JLabel l1 = new JLabel("账号");
    JLabel l2 = new JLabel("密码");
    final JTextField j = new JTextField(15);
    final JPasswordField j1 =new JPasswordField(15);
    JCheckBox jc1 = new JCheckBox("记住密码");
    JCheckBox jc2 = new JCheckBox("自动登录");
    JButton jb = new JButton("登录");
    JButton jb1 = new JButton("退出");
    //事件处理弹窗
    
    jb.addMouseListener(new MouseListener() {
        @Override
        public void mouseReleased(MouseEvent arg0) {
            if(j.getText().equals("notebook")&&
                    String.valueOf(j1.getPassword()).equals("123"))
                    {
                frm.setVisible(false);
Icon icon=new ImageIcon("1966053082.jpg");
                 JOptionPane.showMessageDialog(null, "登陆成功", 
                         "欢迎回来",JOptionPane.INFORMATION_MESSAGE,icon);
                    }
                    else
                    {
                        JOptionPane.showMessageDialog(null, "密码错误", 
                                 "错误",JOptionPane.ERROR_MESSAGE);
                    }    
                    }

        @Override
        public void mouseClicked(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 mousePressed(MouseEvent e) {
            // TODO Auto-generated method stub
            
        }});



    p1.add(l1);
    p1.add(j);
    iwp.add(p1);
    p2.add(l2);
    p2.add(j1);
    iwp.add(p2);
    p3.add(jc1);
    p3.add(jc2);
    iwp.add(p3);
    p4.add(jb);
    p4.add(jb1);
    iwp.add(p4);
    
    frm.add(wp, BorderLayout.CENTER);
    
    ButtonHandler jb1Handler=new ButtonHandler();
    
    jb1.addActionListener(jb1Handler);

frm.setBounds(400,200,500,400);
frm.setVisible(true);

}

}
class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
System.exit(0);
}
}905896-20160319151421178-685969513.png

---恢复内容结束---

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;

public class DengLu {

public static void main(String[]args){
    final JFrame frm=new JFrame("系统登录");
    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    


    JPanel soPanel = new JPanel();
    
    frm.add(soPanel,BorderLayout.NORTH);

    JPanel topPanel = new JPanel();
    frm.add(topPanel,BorderLayout.EAST );
    //图
    Icon t3 = new ImageIcon("1191333.gif");
    JLabel l71 = new JLabel(t3); 
    l71.setBounds(0,0,t3.getIconWidth(),t3.getIconHeight());       
    soPanel.add(l71);
    
    
    JPanel wp = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JPanel iwp = new JPanel();
    wp.add(iwp);
    iwp.setLayout(new GridLayout(4, 1));
    JPanel p1 = new JPanel();
    JPanel p2 = new JPanel();
    JPanel p3 = new JPanel();
    JPanel p4 = new JPanel();
    JLabel l1 = new JLabel("账号");
    JLabel l2 = new JLabel("密码");
    final JTextField j = new JTextField(15);
    final JPasswordField j1 =new JPasswordField(15);
    JCheckBox jc1 = new JCheckBox("记住密码");
    JCheckBox jc2 = new JCheckBox("自动登录");
    JButton jb = new JButton("登录");
    JButton jb1 = new JButton("退出");
    //事件处理弹窗
    
    jb.addMouseListener(new MouseListener() {
        @Override
        public void mouseReleased(MouseEvent arg0) {
            if(j.getText().equals("notebook")&&
                    String.valueOf(j1.getPassword()).equals("123"))
                    {
                frm.setVisible(false);
Icon icon=new ImageIcon("1966053082.jpg");
                 JOptionPane.showMessageDialog(null, "登陆成功", 
                         "欢迎回来",JOptionPane.INFORMATION_MESSAGE,icon);
                    }
                    else
                    {
                        JOptionPane.showMessageDialog(null, "密码错误", 
                                 "错误",JOptionPane.ERROR_MESSAGE);
                    }    
                    }

        @Override
        public void mouseClicked(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 mousePressed(MouseEvent e) {
            // TODO Auto-generated method stub
            
        }});



    p1.add(l1);
    p1.add(j);
    iwp.add(p1);
    p2.add(l2);
    p2.add(j1);
    iwp.add(p2);
    p3.add(jc1);
    p3.add(jc2);
    iwp.add(p3);
    p4.add(jb);
    p4.add(jb1);
    iwp.add(p4);
    
    frm.add(wp, BorderLayout.CENTER);
    
    ButtonHandler jb1Handler=new ButtonHandler();
    
    jb1.addActionListener(jb1Handler);

frm.setBounds(400,200,500,400);
frm.setVisible(true);

}

}
class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
System.exit(0);
}
}905896-20160319151421178-685969513.png

905896-20160319151630068-1148180113.jpg

转载于:https://www.cnblogs.com/liuyuxi2016/p/5295284.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值