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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
package guiTest;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Composite;
public class fenetre2 extends Composite{
Label label1;
Label label2;
Label label3;
Label label4;
Label label5;
Label label6;
Label label7;
Image imageBtn1 ;
public fenetre2(Composite parent, int style,Display d) {
super(parent, style);
GridLayout gridLayout = new GridLayout();
gridLayout.marginWidth=25 ;
gridLayout.verticalSpacing=10 ;
gridLayout.numColumns = 2;
setLayout(gridLayout);
Image img=new Image(this.getDisplay(),"SAVE.bmp") ;
Image img2=new Image(this.getDisplay(),"DELETE.bmp") ;
imageBtn1 = new Image(this.getDisplay(), "fond-page.JPG");
Font font = new Font(d, "Arial", 9, SWT.BOLD);
label1 = new Label(this, SWT.NONE );
label1.setText("ID :");
label1.setFont(font);
final Text text1 = new Text(this, SWT.BORDER | SWT.READ_ONLY );
text1.setBackgroundImage(imageBtn1) ;
label2 = new Label(this, SWT.NONE);
label2.setFont(font);
label2.setText("name:");
final Text text2 = new Text(this, SWT.BORDER);
label3 = new Label(this, SWT.NONE);
label3.setFont(font);
label3.setText("firstname :");
final Text text3 = new Text(this, SWT.BORDER);
label4 = new Label(this, SWT.NONE);
label4.setFont(font);
label4.setText("Mail :");
final Text text4 = new Text(this, SWT.BORDER);
label5 = new Label(this, SWT.NONE);
label5.setFont(font);
label5.setText("Phone :");
final Text text5 = new Text(this, SWT.BORDER);
label6 = new Label(this, SWT.NONE);
label6.setFont(font);
label6.setText("Title :");
final Text text6 = new Text(this, SWT.BORDER);
label7 = new Label(this, SWT.NONE);
label7.setFont(font);
label7.setText("Institut :");
final Combo combo = new Combo(this, SWT.BORDER);
combo.add("element 1 ");
combo.add("element 2 ");
combo.add("element 3 ");
combo.add("element 4 ");
Button button1 = new Button(this, SWT.NONE);
button1.setImage(img) ;
button1.setFont(font);
button1.setText(" Enregister ");
button1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
if(text4.getText().matches(".+@.+\\.[a-z]+"))
System.out.println("OK") ;
else
{ int style = SWT.ICON_ERROR; */
MessageBox messageBox = new MessageBox(this, style);
messageBox.setMessage("Adresse Email n'est pas correcte");
messageBox.open();
}
}
});
Button button2 = new Button(this, SWT.NONE);
button2.setImage(img2) ;
button2.setFont(font);
button2.setText(" Effacer ");
button2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
text2.setText("");
text3.setText("") ;
text4.setText("") ;
text5.setText("") ;
text6.setText("") ;
combo.deselectAll();
}
});
GridData data = new GridData();
data.widthHint = 100;
text1.setLayoutData(data);
text2.setLayoutData(data);
text3.setLayoutData(data);
text4.setLayoutData(data);
text5.setLayoutData(data);
text6.setLayoutData(data);
combo.setLayoutData(data);
GridData dg = new GridData();
dg.verticalIndent = 30;
button1.setLayoutData(dg);
button2.setLayoutData(dg) ;
this.setBackgroundImage(imageBtn1) ;
this.setBG(imageBtn1) ;
}
public void setBG(Image imageBtn1){
label1.setBackgroundImage(imageBtn1) ;
label2.setBackgroundImage(imageBtn1) ;
label3.setBackgroundImage(imageBtn1) ;
label4.setBackgroundImage(imageBtn1) ;
label5.setBackgroundImage(imageBtn1) ;
label6.setBackgroundImage(imageBtn1) ;
label7.setBackgroundImage(imageBtn1) ;
}
} |
Partager