Guest User

Untitled

a guest
Oct 11th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class Fenetre {
  2.  
  3. Panneau pano;
  4.  
  5. public Fenetre() {
  6. JFrame frame = new JFrame();
  7. frame.setTitle("ma fenetre");
  8. frame.setSize(300, 300);
  9. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  10. frame.setVisible(true);
  11.  
  12. pano = new Panneau();
  13.  
  14. JPanel pan = new JPanel();
  15. pan.setBackground(Color.PINK);
  16. frame.getContentPane().add(pano);
  17.  
  18. }
  19.  
  20. public static void main(String[] args) throws InterruptedException {
  21.  
  22. Fenetre fenetre = new Fenetre();
  23. fenetre.go();
  24. }
  25.  
  26. public void go() throws InterruptedException {
  27. for (int i = 0; i < 120; i++) {
  28. int a = pano.getX();
  29. int b = pano.getY();
  30. a++;
  31. b++;
  32. pano.setX(a);
  33. pano.setY(b);
  34.  
  35. System.out.println(a);
  36.  
  37. pano.repaint();
  38. Thread.sleep(50);
  39.  
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment