Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class gameBoardPanel extends JPanel {
- private BufferedImage img;
- item [][] polozky = new item [10][8];
- JLabel background;
- public gameBoardPanel ()
- {
- Random ran = new Random();
- setLayout(new GridLayout(8,10));
- for(int i = 0; i < 10; i++) {
- for(int j = 0; j < 8; j++) {
- int x = ran.nextInt(4);
- polozky[i][j] = new item();
- if(x==0)
- {
- background=new JLabel(new ImageIcon("rectangle.png"));
- }
- else if (x==1)
- {
- background=new JLabel(new ImageIcon("ytriangle.png"));
- }
- else if (x==2)
- {
- background=new JLabel(new ImageIcon("hexagon.png"));
- }
- else if (x==3)
- {
- background=new JLabel(new ImageIcon("diamant.png"));
- }
- polozky[i][j].add(background);
- this.add(polozky[i][j]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement