<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("請(qǐng)輸入郵箱和密碼");
           //用戶名、密碼以及其輸入框
           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("郵件登陸");//窗口標(biāo)題
           
           //以下為加入面版
           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);//設(shè)置大小
           this.setVisible(true);//設(shè)置可見
          
           setResizable(false);//禁止拉動(dòng)窗口大小
           //居中窗口
           Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((screen.width - getSize().width)/2,(screen.height - getSize().height)/2 );
      
          // this.setDefaultCloseOperation(3);//關(guān)閉窗口
        this.addWindowListener(new WindowClose());
           }
           //對(duì)郵箱的輸入格式進(jìn)行判斷
           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;
           }
           //郵箱檢測(cè)
           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("請(qǐng)輸入郵箱");
           // tName.setText("");//清空輸入內(nèi)容
            pPwd.setText("");//清空輸入內(nèi)容
            tName.grabFocus();
           }else if(name.indexOf("@")== -1){
            Message.setForeground(Color.red);
            Message.setText("您輸入郵箱格式錯(cuò)誤,不包含“@”");
            //tName.setText("");
            pPwd.setText("");//清空輸入內(nèi)容
            tName.grabFocus();
           }else if(first<65 || (first>90 && first <97)||first>122){
            Message.setForeground(Color.red);
            Message.setText("郵箱首字母應(yīng)為英文字母");
           // tName.setText("");
            pPwd.setText("");//清空輸入內(nèi)容
            tName.grabFocus();
           }else if(!booFormat){
            Message.setForeground(Color.red);
            Message.setText("郵箱名不和法:只能包含字母、數(shù)字、下劃線");
            //tName.setText("");
            pPwd.setText("");//清空輸入內(nèi)容
            tName.grabFocus();
           }else if(!boo){
            Message.setForeground(Color.red);
            Message.setText("郵箱后綴不和法");
            //tName.setText("");
            pPwd.setText("");//清空輸入內(nèi)容
            tName.grabFocus();
           }else if(password.equals("")){
            Message.setForeground(Color.red);
            Message.setText("密碼不能為空");
            pPwd.setText("");//清空輸入內(nèi)容
            pPwd.grabFocus();
           }else if(password.length()<6){
            Message.setForeground(Color.red);
            Message.setText("密碼必須為6位,請(qǐng)檢查后重新輸入");
            pPwd.setText("");//清空輸入內(nèi)容
            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("郵箱或密碼錯(cuò)誤!請(qǐng)重新輸入!");
            pPwd.setText("");//清空輸入內(nèi)容
            tName.grabFocus();
           }
          }
           }
    //    重置鍵清空輸入內(nèi)容
          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) 評(píng)論(3)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲bt加勒比一区二区| 国产亚洲蜜芽精品久久| 四虎成人免费观看在线网址| 色吊丝免费观看网站| 亚洲国产第一站精品蜜芽| 免费人成在线视频| 国产综合免费精品久久久| 99久久国产亚洲综合精品| 亚洲色无码专区在线观看| 2021免费日韩视频网| 国产日韩在线视频免费播放| 亚洲黄色激情视频| 亚洲一区精彩视频| 日韩一卡2卡3卡4卡新区亚洲| 国产免费不卡视频| 永久免费无码网站在线观看个| 中文字幕在线观看亚洲| 亚洲国产综合无码一区二区二三区| 亚洲精品在线免费看| 黄页网站在线免费观看| 亚洲五月丁香综合视频| 国产亚洲人成网站观看| 免费看大黄高清网站视频在线| 久久这里只精品国产免费10| 99亚洲男女激情在线观看| 亚洲春色另类小说| 日韩亚洲欧洲在线com91tv| 国产无遮挡裸体免费视频 | 亚洲性一级理论片在线观看| 亚洲日韩国产成网在线观看| 最近最新的免费中文字幕| 午夜视频免费在线观看| 春意影院午夜爽爽爽免费| 亚洲另类无码一区二区三区| 亚洲精品美女久久久久| 亚洲精品蜜桃久久久久久| 亚洲Av无码乱码在线播放| 波多野结衣久久高清免费| 毛片无码免费无码播放| 中文精品人人永久免费| 无遮挡免费一区二区三区|