public QP4_PriceDistance(GasSAXManager _gasSAXReader) { que = new Q4_PriceDistance(_gasSAXReader); try { Label label1 = new Label(new String("4/4 The last, which one is")); Label label2 = new Label(new String(" more important?")); CheckboxGroup choiceGroup = new CheckboxGroup(); cBox_Price = new Checkbox(Q4_PriceDistance.PRICE_STR, choiceGroup, true); cBox_Price.setForeground(Color.WHITE); cBox_Distance = new Checkbox(Q4_PriceDistance.DISTANCE_STR, false); cBox_Distance.setForeground(Color.WHITE); cBox_Price.addItemListener(this); cBox_Distance.addItemListener(this); cBox_Distance.setCheckboxGroup(choiceGroup); label1.setForeground(Color.WHITE); label2.setForeground(Color.WHITE); label1.setBounds(new Rectangle(17, 58, 165, 21)); label2.setBounds(new Rectangle(38, 78, 127, 16)); this.setLayout(null); cBox_Price.setBounds(new Rectangle(38, 101, 118, 22)); cBox_Distance.setBounds(new Rectangle(38, 126, 119, 22)); this.add(cBox_Price, null); this.add(cBox_Distance, null); this.add(label1, null); this.add(label2, null); } catch (Exception ex) { ex.printStackTrace(); } }
/** Création de l'intérieur de la fenêtre */ private void initConteneur() { // le fond fond = getToolkit().getImage("./images/preference/bomber_fond.gif"); tracker = new MediaTracker(this); tracker.addImage(fond, 0); try { tracker.waitForID(0); } catch (Exception a) { System.out.println("Erreur lors chargement de l'image: initConteneur() Preference"); a.printStackTrace(); } // le layout manager GridBagLayout layout = new GridBagLayout(); setLayout(layout); GridBagConstraints c = new GridBagConstraints(); c.weightx = 10; c.weighty = 10; c.ipadx = 10; c.ipady = 10; c.fill = GridBagConstraints.BOTH; // label "Joueurs:" Label lbl_joueurs = new Label("Joueurs:"); lbl_joueurs.setAlignment(Label.CENTER); lbl_joueurs.setFont(new Font("SansSerif", Font.BOLD, 16)); lbl_joueurs.setBackground(Color.black); lbl_joueurs.setForeground(Color.red); c.gridx = 0; c.gridy = 0; c.gridwidth = 6; c.gridheight = 1; c.insets = new Insets(20, 10, 10, 10); c.anchor = GridBagConstraints.SOUTH; layout.setConstraints(lbl_joueurs, c); add(lbl_joueurs); // choix de couleur du joueur ayant l'identifiant 0 choix_couleur0 = new Choice(); choix_couleur0.addItem("rouge"); choix_couleur0.addItem("bleu"); choix_couleur0.addItemListener(this); choix_couleur0.setBackground(Color.red); choix_couleur0.setForeground(Color.black); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.gridheight = 1; c.insets = new Insets(10, 10, 5, 20); c.anchor = GridBagConstraints.EAST; layout.setConstraints(choix_couleur0, c); add(choix_couleur0); // nom du joueur ayant l'identifiant 0 txt_joueur0 = new TextField(noms[0]); c.gridx = 2; c.gridy = 1; c.gridwidth = 4; c.gridheight = 1; c.insets = new Insets(10, 10, 5, 20); c.anchor = GridBagConstraints.WEST; layout.setConstraints(txt_joueur0, c); add(txt_joueur0); // choix de couleur du joueur ayant l'identifiant 1 choix_couleur1 = new Choice(); choix_couleur1.addItem("bleu"); choix_couleur1.addItem("rouge"); choix_couleur1.addItemListener(this); choix_couleur1.setBackground(Color.blue); choix_couleur1.setForeground(Color.black); c.gridx = 0; c.gridy = 2; c.gridwidth = 2; c.gridheight = 1; c.insets = new Insets(10, 10, 20, 20); c.anchor = GridBagConstraints.EAST; layout.setConstraints(choix_couleur1, c); add(choix_couleur1); // nom du joueur ayant l'identifiant 1 txt_joueur1 = new TextField(noms[1]); c.gridx = 2; c.gridy = 2; c.gridwidth = 4; c.gridheight = 1; c.insets = new Insets(10, 10, 30, 20); c.anchor = GridBagConstraints.WEST; layout.setConstraints(txt_joueur1, c); add(txt_joueur1); // label "Nombre De Vies:" Label lbl_nbvies = new Label("Nombre De Vies:"); lbl_nbvies.setAlignment(Label.CENTER); lbl_nbvies.setFont(new Font("SansSerif", Font.BOLD, 14)); lbl_nbvies.setBackground(Color.black); lbl_nbvies.setForeground(Color.yellow); c.gridx = 0; c.gridy = 4; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(20, 10, 5, 10); c.anchor = GridBagConstraints.CENTER; layout.setConstraints(lbl_nbvies, c); add(lbl_nbvies); // un choix possible cbg_vies = new CheckboxGroup(); Checkbox cb; for (int i = 1; i <= 5; i++) { if (i == nb_vies) cb = new Checkbox("" + i, cbg_vies, true); else cb = new Checkbox("" + i, cbg_vies, false); c.gridx = i; c.gridy = 4; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(20, 10, 5, 10); c.anchor = GridBagConstraints.CENTER; layout.setConstraints(cb, c); add(cb); } // for // label "Nombre De Victoires:" lbl_victoires = new Label(); lbl_victoires.setAlignment(Label.CENTER); lbl_victoires.setFont(new Font("SansSerif", Font.BOLD, 14)); lbl_victoires.setText("Nombre De Victoires: " + nb_victoires); lbl_victoires.setBackground(Color.black); lbl_victoires.setForeground(Color.green); c.gridx = 0; c.gridy = 6; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(20, 10, 5, 10); c.anchor = GridBagConstraints.CENTER; layout.setConstraints(lbl_victoires, c); add(lbl_victoires); // choix du nombre de victoires entre un 1 et 9 sb_victoires = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 10); sb_victoires.setUnitIncrement(1); sb_victoires.setBlockIncrement(2); sb_victoires.addAdjustmentListener(this); sb_victoires.setValue(nb_victoires); c.gridx = 1; c.gridy = 6; c.gridwidth = 5; c.gridheight = 1; c.insets = new Insets(20, 10, 5, 10); c.anchor = GridBagConstraints.CENTER; layout.setConstraints(sb_victoires, c); add(sb_victoires); // tirage aléatoire des niveaux cb_aleatoire = new Checkbox("Niveaux Aléatoires", aleatoire); cb_aleatoire.setFont(new Font("SansSerif", Font.BOLD, 14)); cb_aleatoire.setBackground(Color.black); cb_aleatoire.setForeground(Color.magenta); c.gridx = 0; c.gridy = 8; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(20, 12, 5, 10); c.anchor = GridBagConstraints.EAST; layout.setConstraints(cb_aleatoire, c); add(cb_aleatoire); // label "FPS:" nombre de frames par seconde lbl_fps = new Label(); lbl_fps.setAlignment(Label.CENTER); lbl_fps.setFont(new Font("SansSerif", Font.BOLD, 14)); lbl_fps.setText("FPS: " + fps); lbl_fps.setBackground(Color.black); lbl_fps.setForeground(Color.orange); c.gridx = 0; c.gridy = 10; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(20, 10, 5, 10); c.anchor = GridBagConstraints.CENTER; layout.setConstraints(lbl_fps, c); add(lbl_fps); // choix du nombre de frames par seconde sb_fps = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 51); sb_fps.setUnitIncrement(1); sb_fps.setBlockIncrement(10); sb_fps.addAdjustmentListener(this); sb_fps.setValue(fps); c.gridx = 1; c.gridy = 10; c.gridwidth = 5; c.gridheight = 1; c.insets = new Insets(20, 10, 5, 10); c.anchor = GridBagConstraints.CENTER; layout.setConstraints(sb_fps, c); add(sb_fps); // bouton de confirmation button_ok = new Button("Ok"); c.gridx = 0; c.gridy = 12; c.gridwidth = 6; c.gridheight = 1; c.insets = new Insets(20, 5, 20, 5); c.anchor = GridBagConstraints.CENTER; layout.setConstraints(button_ok, c); add(button_ok); button_ok.addActionListener(this); } // initConteneur()