洛神賦

          子虛烏有

            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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 景泰县| 伊宁县| 卓尼县| 桦川县| 武陟县| 辽阳市| 手机| 依安县| 日土县| 赤城县| 绥宁县| 丹棱县| 班玛县| 平安县| 天台县| 灌云县| 塔河县| 正镶白旗| 高邮市| 大石桥市| 灵寿县| 杂多县| 泸溪县| 罗山县| 青阳县| 甘泉县| 孟津县| 青浦区| 平乐县| 宝应县| 三门峡市| 通化市| 封丘县| 黄平县| 宜兴市| 江门市| 荆州市| 雷山县| 开阳县| 施甸县| 西昌市|