<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 39,  comments - 44,  trackbacks - 0

    package Pro123;

    import java.awt.Color;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;

    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;

    public class Demo extends JFrame{
        /**
      *
      */
     private static final long serialVersionUID = 1L;
     JOptionPane pane1 = new JOptionPane();
     JFrame frame = new JFrame();
         Container contentPane = frame.getContentPane();
           JLabel Message = new JLabel("請輸入郵箱和密碼");
           //用戶名、密碼以及其輸入框
           JLabel Name = new JLabel("用戶名");
           JLabel Password = new JLabel("密   碼");
           JTextField tName = new JTextField(12);
           JPasswordField pPwd = new JPasswordField(12);
           //按扭
           JButton btnDl = new JButton("登陸");
           JButton btnCz = new JButton("重置");
         
          
           JPanel pToppane = new JPanel();
           JPanel pCenterpane = new JPanel();
           JPanel pCenterpaneName = new JPanel();
           JPanel pCenterpanePwd = new JPanel();
           JPanel pButton = new JPanel();
          
           Demo(){
          
           this.setTitle("郵件登陸");//窗口標題
           
           //以下為加入面版
           pCenterpaneName.add(Name);
           pCenterpaneName.add(tName);
          
           pCenterpanePwd.add(Password);
           pCenterpanePwd.add(pPwd);
          
           pCenterpane.add(pCenterpaneName,"North");
           pCenterpane.add(pCenterpanePwd,"South");
          
           pToppane.add(Message);
         
           pButton.add(btnDl);
           pButton.add(btnCz);
           btnDl.addActionListener(new neibu1());
           btnCz.addActionListener(new neibu2());
          
           add(pToppane,"North");
           add(pCenterpane,"Center");
           add(pButton,"South");
          
          
           this.setSize(250,180);//設置大小
           this.setVisible(true);//設置可見
          
           setResizable(false);//禁止拉動窗口大小
           //居中窗口
           Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((screen.width - getSize().width)/2,(screen.height - getSize().height)/2 );
      
          // this.setDefaultCloseOperation(3);//關閉窗口
        this.addWindowListener(new WindowClose());
           }
           //對郵箱的輸入格式進行判斷
           public boolean validateEmailName(String name){
            String emailName = name.substring(0,name.indexOf('@'));
            boolean booFormat = true;
            int temp = -1;
            for(int i=0;i<emailName.length();i++){
             temp = name.charAt(i);
             A:if(temp<65){
              if(temp>48 && temp<57)
               break A;
              booFormat = false;
              break;
             }
             B:if(temp>90 && temp<97){
              if(temp == 95)
               break B;
              booFormat = false;
              break;
             }
            }
            return booFormat;
           }
           //郵箱檢測
           public boolean validateStationName(String name){
            String stationName = name.substring(name.indexOf('@')+1);
            boolean boo = true;
            if(stationName.indexOf('.') == -1){
             boo = false;
            }else if(stationName.indexOf('.') == 0){
             boo = false;
            }
            return boo;
           }
          
           //事件
      
         
          class  neibu1 implements ActionListener {
          public void actionPerformed(ActionEvent e){
           String name = tName.getText().trim();
           String password = new String(pPwd.getPassword()).trim();
           int first = 0;
           @SuppressWarnings("unused")
       boolean booFromat = false;
           boolean boo = false;
          
           boolean booFormat = false;
       if(name.length()>0){
            first = name.charAt(0);
            if(name.indexOf("@")!= -1){
             booFormat = validateEmailName(name);
             boo = validateStationName(name);
            }
           }
           if(name.equals("")){
            Message.setForeground(Color.red);
            Message.setText("請輸入郵箱");
           // tName.setText("");//清空輸入內容
            pPwd.setText("");//清空輸入內容
            tName.grabFocus();
           }else if(name.indexOf("@")== -1){
            Message.setForeground(Color.red);
            Message.setText("您輸入郵箱格式錯誤,不包含“@”");
            //tName.setText("");
            pPwd.setText("");//清空輸入內容
            tName.grabFocus();
           }else if(first<65 || (first>90 && first <97)||first>122){
            Message.setForeground(Color.red);
            Message.setText("郵箱首字母應為英文字母");
           // tName.setText("");
            pPwd.setText("");//清空輸入內容
            tName.grabFocus();
           }else if(!booFormat){
            Message.setForeground(Color.red);
            Message.setText("郵箱名不和法:只能包含字母、數字、下劃線");
            //tName.setText("");
            pPwd.setText("");//清空輸入內容
            tName.grabFocus();
           }else if(!boo){
            Message.setForeground(Color.red);
            Message.setText("郵箱后綴不和法");
            //tName.setText("");
            pPwd.setText("");//清空輸入內容
            tName.grabFocus();
           }else if(password.equals("")){
            Message.setForeground(Color.red);
            Message.setText("密碼不能為空");
            pPwd.setText("");//清空輸入內容
            pPwd.grabFocus();
           }else if(password.length()<6){
            Message.setForeground(Color.red);
            Message.setText("密碼必須為6位,請檢查后重新輸入");
            pPwd.setText("");//清空輸入內容
            pPwd.grabFocus();
           }else if(name.equals("java@svse.com")&&password.equals("jackrose")){
            Message.setForeground(Color.blue);
            Message.setText("歡迎"+name+"登陸");
           }else{
            Message.setForeground(Color.red);
            Message.setText("郵箱或密碼錯誤!請重新輸入!");
            pPwd.setText("");//清空輸入內容
            tName.grabFocus();
           }
          }
           }
    //    重置鍵清空輸入內容
          class neibu2 implements ActionListener {
        
          public void actionPerformed(ActionEvent e){
           pPwd.setText("");
           tName.setText("");
          }
          }
          class WindowClose extends WindowAdapter{
          public void windowClosing(WindowEvent e){
          
          System.exit(0);
          }
          }
          //MAIN方法
           public static void main(String[]args){
            new Demo();
           }

     
    }

    posted on 2008-05-20 18:11 礦礦 閱讀(1125) 評論(3)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 你是我的城池营垒免费观看完整版| 免费阿v网站在线观看g| 成在人线av无码免费高潮喷水 | 亚洲色少妇熟女11p| 一级做a爰片久久毛片免费陪 | 色噜噜亚洲男人的天堂| av成人免费电影| 一二三四在线播放免费观看中文版视频| 免费午夜爽爽爽WWW视频十八禁| 亚洲av无码专区国产乱码在线观看| 亚洲码和欧洲码一码二码三码| 国产免费一区二区视频| 免费一级特黄特色大片在线| 亚洲第一se情网站| 猫咪社区免费资源在线观看| 久久精品国产亚洲av麻豆| a毛片视频免费观看影院| 亚洲av日韩av激情亚洲| 国产精品午夜免费观看网站| 亚洲AV永久无码精品水牛影视| 最新国产乱人伦偷精品免费网站 | 久久亚洲国产成人精品无码区| 亚洲香蕉久久一区二区| 免费黄色小视频网站| 亚洲一区在线观看视频| 日韩免费高清大片在线| 亚洲熟妇无码另类久久久| 高h视频在线免费观看| 日本久久久免费高清| 亚洲一卡2卡三卡4卡无卡下载| 日韩在线免费看网站| kk4kk免费视频毛片| 亚洲AV日韩AV永久无码免下载| 中文字幕无码免费久久99| 水蜜桃视频在线观看免费| 国产又黄又爽又刺激的免费网址| 国产99在线|亚洲| 免费人成激情视频| 免费国产污网站在线观看15| 亚洲乱妇熟女爽到高潮的片| 亚洲精品无码久久久久去q|