Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. public class gameBoardPanel extends JPanel {
  2.  
  3.  
  4. private BufferedImage img;
  5.  
  6.  
  7. item [][] polozky = new item [10][8];
  8.  
  9. JLabel background;
  10.  
  11.  
  12. public gameBoardPanel ()
  13. {
  14.  
  15.  
  16.  
  17. Random ran = new Random();
  18. setLayout(new GridLayout(8,10));
  19. for(int i = 0; i < 10; i++) {
  20. for(int j = 0; j < 8; j++) {
  21. int x = ran.nextInt(4);
  22.  
  23. polozky[i][j] = new item();
  24.  
  25. if(x==0)
  26. {
  27. background=new JLabel(new ImageIcon("rectangle.png"));
  28. }
  29.  
  30. else if (x==1)
  31. {
  32. background=new JLabel(new ImageIcon("ytriangle.png"));
  33.  
  34. }
  35.  
  36. else if (x==2)
  37. {
  38. background=new JLabel(new ImageIcon("hexagon.png"));
  39.  
  40. }
  41. else if (x==3)
  42. {
  43. background=new JLabel(new ImageIcon("diamant.png"));
  44.  
  45. }
  46.  
  47.  
  48.  
  49. polozky[i][j].add(background);
  50. this.add(polozky[i][j]);
  51.  
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement