コード例 #1
0
ファイル: About.java プロジェクト: annsofi/kalken
  public About() {
    cl = ClassLoader.getSystemClassLoader();

    // ----------------------------------------CENTER--------------------------------//
    imgAbout = new ImageIcon(cl.getResource("om.png"));

    lblAbout = new JLabel(imgAbout);

    lblAbout.setBounds(0, 0, 450, 263);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(null);
    pnlCenter.add(lblAbout);

    btnOk = new JButton(new ImageIcon(cl.getResource("ok.png")));
    btnOk.setBounds(390, 215, 40, 30);
    pnlCenter.add(btnOk);
    btnOk.addActionListener(this);

    // -----------------------------------CONTAINER----------------------------------//
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(pnlCenter, BorderLayout.CENTER);
    setSize(450, 280);
    setVisible(true);
    setResizable(false);
    setLocation(580, 280);
    // setDefaultCloseOperation(EXIT_ON_CLOSE);

  }
コード例 #2
0
ファイル: IHM.java プロジェクト: nd4pa/tp
  /*Classe de traitement des évenement
   *@param e objet Evénement
   *@see ActionListener
   *@author Arnaud Prémel-Cabic
   *@author Antoine Blondeau
   */
  public void actionPerformed(ActionEvent e) {
    int tmp = 0;
    if (e.getSource() == bPierre) {
      tmp = ppc.duel(1);
      if (ppc.getIAChoix() == 2) {
        imageAction2.setIcon(pierre);
      }
      if (ppc.getIAChoix() == 1) {
        imageAction2.setIcon(papier);
      }
      if (ppc.getIAChoix() == 3) {
        imageAction2.setIcon(ciseaux);
      }
      imageAction1.setIcon(papier);
    }
    if (e.getSource() == bPapier) {
      tmp = ppc.duel(2);
      if (ppc.getIAChoix() == 2) {
        imageAction2.setIcon(pierre);
      }
      if (ppc.getIAChoix() == 1) {
        imageAction2.setIcon(papier);
      }
      if (ppc.getIAChoix() == 3) {
        imageAction2.setIcon(ciseaux);
      }
      imageAction1.setIcon(pierre);
    }
    if (e.getSource() == bCiseaux) {
      tmp = ppc.duel(3);
      if (ppc.getIAChoix() == 2) {
        imageAction2.setIcon(pierre);
      }
      if (ppc.getIAChoix() == 1) {
        imageAction2.setIcon(papier);
      }
      if (ppc.getIAChoix() == 3) {
        imageAction2.setIcon(ciseaux);
      }
      imageAction1.setIcon(ciseaux);
    }

    if (e.getSource() == exit) {
      System.exit(1);
    }
    if (tmp < 0) {
      iascore = iascore + 1;
      score2.setText("" + iascore);
      ensemble.setBackground(Color.RED);
      noms.setBackground(Color.RED);
      scores.setBackground(Color.RED);
      action.setBackground(Color.RED);
      selection.setBackground(Color.RED);
      menu.setBackground(Color.RED);
    }
    if (tmp > 0) {
      pscore = pscore + 1;
      score1.setText("" + pscore);
      ensemble.setBackground(Color.GREEN);
      noms.setBackground(Color.GREEN);
      scores.setBackground(Color.GREEN);
      action.setBackground(Color.GREEN);
      selection.setBackground(Color.GREEN);
      menu.setBackground(Color.GREEN);
    }
    if (tmp == 0) {
      ensemble.setBackground(Color.WHITE);
      noms.setBackground(Color.WHITE);
      scores.setBackground(Color.WHITE);
      action.setBackground(Color.WHITE);
      selection.setBackground(Color.WHITE);
      menu.setBackground(Color.WHITE);
    }
    if (e.getSource() == reset) {
      score1.setText("");
      score2.setText("");
      imageAction1.setIcon(vierge);
      imageAction2.setIcon(vierge);

      ensemble.setBackground(null);
      noms.setBackground(null);
      scores.setBackground(null);
      action.setBackground(null);
      selection.setBackground(null);
      menu.setBackground(null);
    }
  }