Advertisement
Guest User

Untitled

a guest
May 25th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.GridBagConstraints;
  3. import java.awt.GridBagLayout;
  4. import javax.swing.JFrame;
  5. import javax.swing.JLabel;
  6.  
  7.  
  8. public class Plansza extends JFrame {
  9. private Pole pola[][];
  10. private int k = 200,
  11. n = 10,
  12. m = 6;
  13. private double probability = 0.5;
  14. private JLabel labels[][];
  15.  
  16. public Plansza() {
  17. setSize(1300, 800);
  18. setVisible(true);
  19. setResizable(false);
  20. setLayout(new GridBagLayout());
  21. GridBagConstraints c = new GridBagConstraints();
  22. c.fill = GridBagConstraints.BOTH;
  23. c.weightx = 1;
  24. c.weighty = 1;
  25.  
  26.  
  27. pola = new Pole[n][m];
  28. labels = new JLabel[n][m];
  29.  
  30. for (int i = 0; i < n; i ++) {
  31. for (int j = 0; j < m; j++) {
  32. labels[i][j] = new JLabel();
  33. labels[i][j].setOpaque(true);
  34. c.gridx = i;
  35. c.gridy = j;
  36.  
  37. add(labels[i][j], c);
  38. pola[i][j] = new Pole(this, i, j);
  39.  
  40. }
  41. }
  42. }
  43.  
  44.  
  45. public synchronized void setColor(Color color, int x, int y) { labels[x][y].setBackground(color); }
  46.  
  47. public double getProbability() { return probability; }
  48.  
  49. public static void main(String args[]) {
  50. new Plansza();
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement