1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | ... public void createControl(Composite parent) { Compositecontainer = new Composite(parent, SWT.NULL); GridLayoutlayout = new GridLayout(); container.setLayout(layout); layout.numColumns = 2; layout.verticalSpacing = 9; Label label= new Label(container, SWT.NULL); label.setText("&Given Name:"); givenNameText = new Text(container, SWT.BORDER | SWT.SINGLE); GridData gd= new GridData(GridData.FILL_HORIZONTAL); givenNameText.setLayoutData(gd); givenNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); label = newLabel(container, SWT.NULL); label.setText("&Family Name:"); familyNameText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = newGridData(GridData.FILL_HORIZONTAL); familyNameText.setLayoutData(gd); familyNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); label = newLabel(container, SWT.NULL); label.setText("&Nickname:"); nickNameText= new Text(container, SWT.BORDER | SWT.SINGLE); gd = newGridData(GridData.FILL_HORIZONTAL); nickNameText.setLayoutData(gd); createLine(container, layout.numColumns); label = newLabel(container, SWT.NULL); label.setText("&Business Phone:"); businessPhoneText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = newGridData(GridData.FILL_HORIZONTAL); businessPhoneText.setLayoutData(gd); label = new Label(container, SWT.NULL); label.setText("&Home Phone:"); homePhoneText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = newGridData(GridData.FILL_HORIZONTAL); homePhoneText.setLayoutData(gd); createLine(container, layout.numColumns); label = newLabel(container, SWT.NULL); label.setText("&E-Mail Address:"); emailText =new Text(container, SWT.BORDER | SWT.SINGLE); gd = newGridData(GridData.FILL_HORIZONTAL); emailText.setLayoutData(gd); emailText.addModifyListener(newModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); //dialogChanged(); setControl(container); } ... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ... private void dialogChanged() { if (this.getGivenName().length() == 0) { updateStatus("Given name must be specified."); return; } if (this.getFamilyName().length() == 0) { updateStatus("Family name must be specified."); return; } if (this.getEmail().length() > 0) { if (this.getEmail().indexOf("@") < 0) { updateStatus("Enter your email address as yourname@yourdomain.com"); return; } } updateStatus(null); } private void updateStatus(String message) { setErrorMessage(message); setPageComplete(message == null); ... |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |