// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class ParagraphCount extends JFrame implements ActionListener {
   private JTextArea txt;

   private JLabel lbl;

   private JButton btn;

   public ParagraphCount() {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      getContentPane().setLayout(new BorderLayout());
      txt = new JTextArea();
      getContentPane().add(txt, BorderLayout.CENTER);
      lbl = new JLabel("0");
      getContentPane().add(lbl, BorderLayout.NORTH);
      btn = new JButton("Count");
      btn.addActionListener(this);
      getContentPane().add(btn, BorderLayout.SOUTH);
      pack();
   }

   public static int count(String boks) {
      int antal = 0;
      for (int i = 0; i < boks.length(); i++) {
         if (boks.charAt(i) == '.') {
            antal++;
         }
      }
      return antal;
   }

   public void actionPerformed(ActionEvent e) {
      lbl.setText("" + count(txt.getText()));
   }

   public static void main(String[] args) {
      ParagraphCount f = new ParagraphCount();
      f.setVisible(true);
   }
}
