洛神賦

          子虛烏有

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            7 Posts :: 10 Stories :: 0 Comments :: 0 Trackbacks
          package Denglv;

          import org.eclipse.jface.dialogs.MessageDialog;
          import org.eclipse.swt.SWT;
          import org.eclipse.swt.events.SelectionAdapter;
          import org.eclipse.swt.events.SelectionEvent;
          import org.eclipse.swt.widgets.Button;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.swt.widgets.Label;
          import org.eclipse.swt.widgets.Shell;
          import org.eclipse.swt.widgets.Text;

          public class Login {

              public static void main(String[] args) {
                  Display display = new Display();
                  final Shell shell = new Shell();
                  shell.setBounds(30, 75, 300, 400);
                  shell.setText("登陸界面");
                 
               // ------------------新插入的界面核心代碼------------------------
            
                  //創建觸發按鈕以及按鈕的顯示文字和大小位置
                  Button okButton = new Button(shell,SWT.NONE);
                  Button registerButton = new Button(shell,SWT.NONE);
                  okButton.setText("確定");
                  registerButton.setText("注冊");
                  registerButton.setBounds(160, 235, 70, 25);
                  okButton.setBounds(60, 235, 70, 25);
                
                  final Text nameText = new Text(shell,SWT.NONE);
                  final Text passNumber = new Text(shell,SWT.PASSWORD);
                  nameText.setBounds(120, 100, 110, 20);
                  passNumber.setBounds(120, 160, 110, 20);
                
                  Label nameLabel = new Label(shell,SWT.NONE);
                  nameLabel.setText("用戶名:");
                  nameLabel.setBounds(65, 100, 40,20);
                
                  Label passLabel = new Label(shell,SWT.NONE);
                  passLabel.setText("密   碼:");
                  passLabel.setBounds(65, 165, 40, 20);
                
                  //輸入后單擊確定后的操作
                  okButton.addSelectionListener(new SelectionAdapter(){
                      public void widgetSelected(SelectionEvent e){
                          //創建一個adm數組
                          Users[] user = new Users[3];
                      
                          user[0] = new Users("123", "123");
                          user[1] = new Users("123456", "123456");
                          user[2] = new Users("123456789", "123456789");
                        
                          int j=-1;
                        
                          //判斷賬號密碼是否正確
                          for(int i=0;i<user.length;i++){
                              if(user[i].getName().equals(nameText.getText())&&user[i].getPastNumber().equals(passNumber.getText())){
                                  j = 0;
                                 break;
                              }
                          }              
                          if(j==0){
                              MessageDialog.openWarning(shell, "恭喜", "歡迎"+nameText.getText()+"登錄");
                          }
                          else{
                               MessageDialog.openError(shell, "錯誤","請輸入正確的用戶名或密碼!");
                          }
                         
                         
                     }
                  }
                
                  );
                
                
                  registerButton.addSelectionListener(new SelectionAdapter(){
                      public void widgetSelected(SelectionEvent e){{
                          //用一個錯誤對話框來提醒該功能還沒有實現
                           MessageDialog.openError(shell, "錯誤","該功能還沒有實現!");
                      }}});
                 
                //-----------------------END-----------------------------------
                  shell.open();
                  while(!shell.isDisposed()){
                      if(!display.readAndDispatch()){
                          display.sleep();
                      }
                  }
                  display.dispose();
                
              }

          }


          class Users{
              private String username;
              private String pastNumber;
            
              Users(String name, String pastNumber){
                  this.username = name;
                  this.pastNumber = pastNumber;
              }

              public String getName() {
                  return username;
              }

              public void setName(String name) {
                  this.username = name;
              }

              public String getPastNumber() {
                  return pastNumber;
              }

              public void setPastNumber(String pastNumber) {
                  this.pastNumber = pastNumber;
              }
            
            
            
          }


          運行結果:
          情況如下
          1、



          2、

          3、




          感謝閱讀!!!!!希望提供寶貴意見!!!!QQ:237333696



















          posted on 2010-11-02 20:14 洛神賦 閱讀(7920) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 天镇县| 桑植县| 甘南县| 贵定县| 绥化市| 海兴县| 西峡县| 房产| 太原市| 华阴市| 肃北| 汪清县| 抚顺县| 竹山县| 东安县| 钟山县| 溆浦县| 东阳市| 新绛县| 广平县| 隆尧县| 嘉黎县| 平乐县| 安福县| 香河县| 璧山县| 龙游县| 美姑县| 民县| 塔城市| 肥城市| 育儿| 江永县| 申扎县| 深州市| 泗洪县| 大理市| 五台县| 广平县| 开原市| 武夷山市|