Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- public class Plansza extends JFrame {
- private Pole pola[][];
- private int k = 200,
- n = 10,
- m = 6;
- private double probability = 0.5;
- private JLabel labels[][];
- public Plansza() {
- setSize(1300, 800);
- setVisible(true);
- setResizable(false);
- setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.fill = GridBagConstraints.BOTH;
- c.weightx = 1;
- c.weighty = 1;
- pola = new Pole[n][m];
- labels = new JLabel[n][m];
- for (int i = 0; i < n; i ++) {
- for (int j = 0; j < m; j++) {
- labels[i][j] = new JLabel();
- labels[i][j].setOpaque(true);
- c.gridx = i;
- c.gridy = j;
- add(labels[i][j], c);
- pola[i][j] = new Pole(this, i, j);
- }
- }
- }
- public synchronized void setColor(Color color, int x, int y) { labels[x][y].setBackground(color); }
- public double getProbability() { return probability; }
- public static void main(String args[]) {
- new Plansza();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement