コード例 #1
0
ファイル: Senso.java プロジェクト: zale90/hg78ijavaprojects
 public void run() {
   try {
     while (läuft) {
       Thread.sleep(1);
       if (verloren) {
         verloren();
       } else {
         if (intro) {
           rot.setIcon(new ImageIcon("files/Minigames/Senso/red_n.png"));
           gruen.setIcon(new ImageIcon("files/Minigames/Senso/green_n.png"));
           blau.setIcon(new ImageIcon("files/Minigames/Senso/blue_n.png"));
           gelb.setIcon(new ImageIcon("files/Minigames/Senso/yellow_n.png"));
           lblVerloren.setText("");
           start.setText("3");
           Thread.sleep(1000);
           start.setText("2");
           Thread.sleep(1000);
           start.setText("1");
           Thread.sleep(1000);
           start.setLocation(start.getX() - 20, start.getY());
           start.setText("Los!");
           Thread.sleep(250);
           start.setText("");
           start.setLocation(start.getX() + 20, start.getY());
           rot.setIcon(new ImageIcon("files/Minigames/Senso/red_0.png"));
           gruen.setIcon(new ImageIcon("files/Minigames/Senso/green_0.png"));
           blau.setIcon(new ImageIcon("files/Minigames/Senso/blue_0.png"));
           gelb.setIcon(new ImageIcon("files/Minigames/Senso/yellow_0.png"));
           intro = false;
           neu = true;
         }
         if (wiedergeben && !verloren) {
           Thread.sleep(500);
           alteFarbe();
         } else if (neu && !verloren) neueFarbe();
         if (!wiedergeben && !neu) {
           String s = "Noch ";
           vKlicks = runde - klick;
           if (vKlicks >= 1) s = s + String.valueOf(vKlicks);
           else s = "";
           klicks.setText(s);
         } else klicks.setText("");
       }
     }
   } catch (Exception e) {
   }
 }
コード例 #2
0
  /**
   * Returns the drag icon used to represent a cell in all drag operations.
   *
   * @param tree the parent tree object
   * @param dragObject the dragged object
   * @param index the index of the dragged object in the tree
   * @return the drag icon
   */
  public Icon getDragIcon(JTree tree, Object dragObject, int index) {
    ContactListTreeCellRenderer dragC =
        (ContactListTreeCellRenderer)
            getTreeCellRendererComponent(
                tree,
                dragObject,
                false, // is selected
                false, // is expanded
                true, // is leaf
                index,
                true // has focus
                );

    // We should explicitly set the bounds of all components in order that
    // they're correctly painted by paintIcon afterwards. This fixes empty
    // drag component in contact list!
    dragC.setBounds(0, 0, dragC.getIconWidth(), dragC.getIconHeight());

    Icon rightLabelIcon = rightLabel.getIcon();
    int imageHeight = 0;
    int imageWidth = 0;
    if (rightLabelIcon != null) {
      imageWidth = rightLabelIcon.getIconWidth();
      imageHeight = rightLabelIcon.getIconHeight();
      dragC.rightLabel.setBounds(tree.getWidth() - imageWidth, 0, imageWidth, imageHeight);
    }

    dragC.statusLabel.setBounds(0, 0, statusLabel.getWidth(), statusLabel.getHeight());

    dragC.nameLabel.setBounds(
        statusLabel.getWidth(), 0, tree.getWidth() - imageWidth - 5, nameLabel.getHeight());

    dragC.displayDetailsLabel.setBounds(
        displayDetailsLabel.getX(),
        nameLabel.getHeight(),
        displayDetailsLabel.getWidth(),
        displayDetailsLabel.getHeight());

    return dragC;
  }
コード例 #3
0
ファイル: carRace.java プロジェクト: ajayaneja896/carRace
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == start) {
      t.start();

      result.setVisible(false);
      scoreValue = 0;
      speed.setText("SPEED " + 40); // this is starting speeed
    }

    if (count % 10 == 0) {
      carNo = CarRace.randInt();

      if (carNo == 1 && flag1 == 0) {
        one.setVisible(true);
        one.setBounds(120, 100, 120, 70);
        pos1 = 100;
        flag1 = 1;
      }
      if (carNo == 2 && flag2 == 0) {
        two.setVisible(true);
        two.setBounds(240, 100, 120, 70);
        pos2 = 100;
        flag2 = 1;
      }

      if (carNo == 3 && flag3 == 0) {
        three.setVisible(true);
        three.setBounds(360, 100, 120, 70);
        pos3 = 100;
        flag3 = 1;
      }
    }

    count++;
    if (count >= 1000) count = 0;

    if (one.isVisible() == true) {
      one.setBounds(120, pos1, 120, 70);
      pos1 += 10;
      if (pos1 > 520) {
        flag1 = 0;
        one.setVisible(false);
      }
    }

    if (two.isVisible() == true) {
      two.setBounds(240, pos2, 120, 70);
      pos2 += 10;
      if (pos2 > 520) {
        flag2 = 0;
        two.setVisible(false);
      }
    }

    if (three.isVisible() == true) {
      three.setBounds(360, pos3, 120, 70);
      pos3 += 10;
      if (pos3 > 520) {
        flag3 = 0;
        three.setVisible(false);
      }
    }

    if (one.getY() + 70 == car.getY() && car.getX() == 120) {
      t.stop();
      result.setText(" SCORE " + scoreValue);
      result.setVisible(true);
    } else if (two.getY() + 70 == car.getY() && car.getX() == 240) {
      t.stop();
      result.setText(" SCORE " + scoreValue);
      result.setVisible(true);
    } else if (three.getY() + 70 == car.getY() && car.getX() == 360) {
      t.stop();
      result.setText(" SCORE " + scoreValue);
      result.setVisible(true);
    }

    scoreValue += 1;
    score.setText("score " + scoreValue);

    int m = 160 - x;
    if (m < 0) m = 0;
    speed.setText("SPEED " + m);
  }