package chainreaction;

import java.awt.*;
import javax.swing.*;

class ChainReactionFrame extends JFrame {

private JLabel threadCountLabel;

public ChainReactionFrame() {
  setTitle("Láncreakció");
  setLocation(40, 40);
  setDefaultCloseOperation(EXIT_ON_CLOSE);
  setLayout(new BorderLayout());
  JPanel chainReactionPanel = new ChainReactionPanel();
  getContentPane().add(chainReactionPanel, BorderLayout.CENTER);
  threadCountLabel = new JLabel();
  threadCountLabel.setFont(new Font("Arial", 0, 30));
  getContentPane().add(threadCountLabel, BorderLayout.SOUTH);
  pack();
  new Thread() {
  @Override
  public void run() {
    while (true) {
      ChainReactionFrame.this.repaint();
      threadCountLabel.setText(Thread.activeCount() + "");
      try {
        Thread.sleep(40);
      } catch (InterruptedException ex) {
      }
    }
  }
  }.start();
}
}
