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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
/* application AWT
* CODE REPRESENTE UNE IMPLÉMENTATION DE RELATION DE COMPOSITION UML
* le placement des composants se fait manuellement/le layout manager est desactiver avec la méthode this.setLayout(null);
*/
package awtprojet;
import java.awt.*;
import java.awt.event.*;
public class Fenetre extends Frame {
private MenuBar menubar;
private Menu menufile,menuedition;
private MenuItem itemnew,itemopen,itemclose,itemcopier,itemcouper,itemcoller;
private Checkbox ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9;
private Label ltitre,l4,l5,l6,l7;
private TextField t1,t2;
private Button bnext,banul;
private CheckboxGroup gr1;
private Choice jours,mois,annee;
private Panel pan1,pan2;
//private Label l1,l2,l3;
public Fenetre(){
super();
//label titre
ltitre=new Label("ETAPE 1");
ltitre.setBounds(260, 70, 150, 30);
ltitre.setFont (new Font ("TimesRoman", Font.BOLD, 20)); // choix de la police
add(ltitre);
//les boutton suivant et annuler
bnext=new Button("suivant");
bnext.setBackground(Color.PINK);
bnext.setBounds(480,500,100, 30);
add(bnext);
banul=new Button("annuler");
banul.setBackground(Color.PINK);
banul.setBounds(350, 500, 100, 30);
add(banul);
// le menubar
menubar=new MenuBar();
setMenuBar(menubar);
menubar.setFont (new Font ("TimesRoman", Font.BOLD, 13));
//les menus
menufile=new Menu("fichier");
menubar.add(menufile);
//menubar.setBackground(Color.PINK);
menuedition=new Menu("edition");
menubar.add(menuedition);
//les menuItem
itemnew=new MenuItem ("new");
menufile.add(itemnew);
itemopen=new MenuItem ("open");
menufile.add(itemopen);
itemclose=new MenuItem ("close");
menufile.add(itemclose);
itemcopier=new MenuItem ("copier");
menuedition.add(itemcopier);
itemcouper=new MenuItem ("couper");
menuedition.add(itemcouper);
itemcoller=new MenuItem ("coller");
menuedition.add(itemcoller);
//panel pour contenir les 3premiers checkbox
Panel pan2=new Panel();
pan2.setBounds(100,140 ,410 ,50 );
pan2.setBackground(Color.LIGHT_GRAY);
add(pan2);
//le groupbox; checkbox avec leurs label(les bouttons radio)
CheckboxGroup gr1 = new CheckboxGroup();
ch1=new Checkbox("Monsieur",gr1,false);
ch1.setBounds(100,140,90,10);
pan2.add(ch1);
//l1=new Label("* Monsieur:");
//l1.setBounds(30,150 , 90, 20);
//l1.setFont (new Font ("TimesRoman", Font.BOLD, 13));
//add(l1);
ch2=new Checkbox("Madame",gr1,false);
ch2.setBounds(250,140,100,10);
pan2.add(ch2);
//l2=new Label("* Madame:");
//l2.setBounds(190,150 ,90 ,20 );
//l2.setFont (new Font ("TimesRoman", Font.BOLD, 13));
//add(l2);
ch3=new Checkbox("Mademoiselle",gr1,false);
ch3.setBounds(380, 140,120, 10);
pan2.add(ch3);
//l3=new Label("* Mademoiselle:");
//l3.setBounds(330, 150, 120, 20);
//l3.setFont (new Font ("TimesRoman", Font.BOLD, 13));
//add(l3);
//les deux label nom & prenom
l4=new Label("* Nom :");
l4.setBounds(100, 200, 70, 30);
l4.setFont (new Font ("TimesRoman", Font.BOLD, 13));
add(l4);
l5=new Label("* Prenom :");
l5.setBounds(100, 250, 90, 30);
l5.setFont (new Font ("TimesRoman", Font.BOLD, 13));
add(l5);
//label et groupbox de choix de langue
l6=new Label("* date de naissance :");
l6.setBounds(100, 300, 170, 30);
l6.setFont (new Font ("TimesRoman", Font.BOLD, 13));
add(l6);
Choice jours = new Choice();
jours.setBounds(270, 300, 60, 30);
jours.setBackground(Color.PINK);
jours.add("jours");
//for(int j=1;j<=31;j++) add(new Choice(Integer.toString(j)));
jours.add("01");
jours.add("02");
jours.add("03");
jours.add("04");
jours.add("05");
jours.add("06");
jours.add("07");
jours.add("08");
jours.add("09");
jours.add("10");
jours.add("11");
jours.add("12");
jours.add("13");
jours.add("14");
jours.add("15");
jours.add("16");
jours.add("17");
jours.add("18");
jours.add("19");
jours.add("20");
jours.add("21");
jours.add("22");
jours.add("23");
jours.add("24");
jours.add("25");
jours.add("26");
jours.add("27");
jours.add("28");
jours.add("29");
jours.add("30");
jours.add("31");
add(jours);
Choice mois = new Choice();
mois.setBounds(330, 300, 90, 30);
mois.setBackground(Color.PINK);
mois.add("mois");
mois.add("janvier");
mois.add("fevrier");
mois.add("mars");
mois.add("avril");
mois.add("mai");
mois.add("juin");
mois.add("juiller");
mois.add("aout");
mois.add("septembre");
mois.add("octobre");
mois.add("novembre");
mois.add("decembre");
add(mois);
Choice annee = new Choice();
annee.setBounds(420, 300, 90, 30);
annee.setBackground(Color.PINK);
annee.add("année");
annee.add("1970");
annee.add("1980");
annee.add("1990");
annee.add("2000");
add(annee);
//les deux zone de texte pour nom & prenom
t1=new TextField();
t1.setBounds(240,200 ,180 ,30 );
t1.setBackground(Color.LIGHT_GRAY);
add(t1);
t2=new TextField();
t2.setBackground(Color.LIGHT_GRAY);
t2.setBounds(240,250 ,180 ,30 );
add(t2);
//label,centre d'interet>panel(pan1)
l7=new Label("* centres d'intéret :");
l7.setBounds(100, 340, 150, 30);
l7.setFont (new Font ("TimesRoman", Font.BOLD, 13));
add(l7);
//ajout d'un Panel ( pan1) et lui inserer des checkbox
//creation du panel
Panel pan1=new Panel();
pan1.setBounds(270,350 ,240 ,130 );
pan1.setBackground(Color.LIGHT_GRAY);
add(pan1);
//dreation des checkbox
ch4 = new Checkbox("sport");
ch5 = new Checkbox("voyage");
ch6 = new Checkbox("cinema");
ch7 = new Checkbox("lecture");
ch8 = new Checkbox("musique");
ch9 = new Checkbox("informatique");
//ajout des checkbox au panel(pan1)
pan1.add(ch4);
pan1.add(ch5);
pan1.add(ch6);
pan1.add(ch7);
pan1.add(ch8);
pan1.add(ch9);
this.setBounds(300, 100, 600, 600);
this.setTitle("MA FENETRE");
this.setBackground(Color.WHITE);
// desactiver le layout manager et positionnement manuel des composants
this.setLayout(null);
//this.setVisible(true);
pack();
show();
}
} |
Partager