• 第二周笔记


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

    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JComboBox;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JTextArea;

    public class zuoye1 {

    /**
     * @param args
     */
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        
        final JFrame f1=new JFrame();
        f1.setLayout(null);
        
        
        
        
        
        
        
        JLabel denglu =new JLabel();
        ImageIcon img = new ImageIcon("image/登录.png");
        denglu.setIcon(img);
        
        
        f1.getLayeredPane().add(denglu,new Integer(Integer.MIN_VALUE));
        denglu.setBounds(0,0,img.getIconWidth(),img.getIconHeight());
        Container cp = f1.getContentPane();
        cp.setLayout(null);
        ((JPanel) cp).setOpaque(false); 
        
        
        final JLabel guanbi =new JLabel();
        ImageIcon img1 = new ImageIcon("image/关闭.png");
        guanbi.setIcon(img1);
        guanbi.setBounds(245, 9, 25, 30);
        guanbi.addMouseListener(new MouseListener() {
            
            @Override
            public void mouseReleased(MouseEvent arg0) {
                // TODO Auto-generated method stub
                System.exit(0);
            }
            
            @Override
            public void mousePressed(MouseEvent arg0) {
                // TODO Auto-generated method stub
                
            }
            
            @Override
            public void mouseExited(MouseEvent arg0) {
                // TODO Auto-generated method stub
                
            }
            
            @Override
            public void mouseEntered(MouseEvent arg0) {
                // TODO Auto-generated method stub
                
            }
            
            @Override
            public void mouseClicked(MouseEvent arg0) {
                // TODO Auto-generated method stub
                
            }
        });
        
        
        JLabel yonghuming =new JLabel("登录用户:");
        yonghuming.setBounds(60,100,80,30);
        
        
        JLabel mima =new JLabel("登录密码:");
        mima.setBounds(60,150,80,30);
        
        
        
             //文本 y m

    ;
    JPanel p=new JPanel();
    p.setLayout(null);
    p.setBounds(130, 108, 120, 80);
    final JPasswordField y =new JPasswordField();
    y.setEchoChar((char) 0);
    y.setBounds(0, 0, 120, 15);

        final JPasswordField m =new JPasswordField();
        m.setEditable(true);
        m.setBounds(0, 50, 120, 15);
        
           //按钮
        final Icon i=new ImageIcon("image/duigou.jpg");
        JButton queding=new JButton("确定");
        queding.setBounds(50,235,60,35);
        queding.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub
                String yong=new String(y.getPassword());
                String mi=new String(m.getPassword());
                if(yong.equals("yxq")&&mi.equals("123"))
                {
                    JOptionPane.showMessageDialog(f1,"登录成功!","登录成功!",JOptionPane.INFORMATION_MESSAGE,i);
                }
                else
                {
                    JOptionPane.showMessageDialog(f1, "您输入的用户名或密码错误!","登录失败!",JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        
        
        
        JButton quxiao=new JButton("取消");
        quxiao.setBounds(190,235,60,35);
        quxiao.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub
                System.exit(0);
                
            }
        });
        
        
        JPanel p1=new JPanel();
        p1.setLayout(null);
        p1.setBounds(50, 180, 200, 25);
        p1.setOpaque(false);
        JCheckBox x1=new JCheckBox("记住密码");
        x1.setBounds(0,0,80,25);
        x1.setOpaque(false);
        JCheckBox x2=new JCheckBox("自动登录");
        x2.setBounds(120,0,80,25);
        x2.setOpaque(false);
        p1.add(x1);
        p1.add(x2);
        
        
        
        
        
        
        
        
    
        p.add(y);
        p.add(m);
        p.setOpaque(false);
        f1.add(p);
        f1.add(p1);
        f1.add(yonghuming);
        f1.add(mima);
        f1.add(guanbi);
    
        f1.add(queding);
        f1.add(quxiao);
        f1.setBounds(400,200,300,300);
        
        
        f1.setUndecorated(true);
        f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f1.setVisible(true);
        
    
    }
  • 相关阅读:
    地球化学图解系统GCDPlot 0.33
    《Excel VBA应用开发从基础到实践》配套源代码
    边缘化的GIS——Traditional GIS No Longer Necessary
    数据库与空间数据库
    本Blog暂停更新,请访问:http://mars.3snews.net
    ArcGIS 9.2 笔记(5):Georocessing与Python
    微软更新Photosynth Technology Preview
    ArcGIS 9.2 笔记(4):数据互操作
    技术日记20130408
    Git服务器Gitosis安装设置
  • 原文地址:https://www.cnblogs.com/zhaofanchao/p/5309925.html
Copyright © 2020-2023  润新知