package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;

public final class MainPanel extends JPanel {
    private final JTextArea textArea = new JTextArea();
    private final Timer timer = new Timer(200, new ActionListener() {
        @Override public void actionPerformed(ActionEvent e) {
            String s = new Date().toString();
            textArea.append(textArea.getDocument().getLength() > 0 ? "\n" + s : s);
        }
    });
    private final JButton start = new JButton(new AbstractAction("Start") {
        @Override public void actionPerformed(ActionEvent e) {
            if (!timer.isRunning()) {
                timer.start();
            }
        }
    });
    private final JButton stop = new JButton(new AbstractAction("Stop") {
        @Override public void actionPerformed(ActionEvent e) {
            timer.stop();
        }
    });
    private final JButton clr = new JButton(new AbstractAction("Clear") {
        @Override public void actionPerformed(ActionEvent e) {
            textArea.setText("");
        }
    });
    public MainPanel() {
        super(new BorderLayout());
        /* //TEST
        ((AbstractDocument) textArea.getDocument()).setDocumentFilter(new FIFODocumentFilter());
        /*/
        textArea.getDocument().addDocumentListener(new FIFODocumentListener(textArea));
        //*/
        textArea.setEditable(false);

        addHierarchyListener(e -> {
            if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0 && !e.getComponent().isDisplayable()) {
                timer.stop();
            }
        });

        Box box = Box.createHorizontalBox();
        box.add(Box.createHorizontalGlue());
        box.add(start);
        box.add(stop);
        box.add(Box.createHorizontalStrut(5));
        box.add(clr);

        add(new JScrollPane(textArea));
        add(box, BorderLayout.SOUTH);
        setPreferredSize(new Dimension(320, 240));
    }

    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        //frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

class FIFODocumentListener implements DocumentListener {
    private static final int MAX_LINES = 10;
    private final JTextComponent textComponent;
    protected FIFODocumentListener(JTextComponent textComponent) {
        this.textComponent = textComponent;
    }
    @Override public void insertUpdate(DocumentEvent e) {
        final Document doc = e.getDocument();
        final Element root = doc.getDefaultRootElement();
        if (root.getElementCount() <= MAX_LINES) {
            return;
        }
        EventQueue.invokeLater(() -> removeLines(doc, root));
        textComponent.setCaretPosition(doc.getLength());
    }
    private static void removeLines(Document doc, Element root) {
        Element fl = root.getElement(0);
        try {
            doc.remove(0, fl.getEndOffset());
        } catch (BadLocationException ble) {
            ble.printStackTrace();
        }
    }
    @Override public void removeUpdate(DocumentEvent e)  { /* not needed */ }
    @Override public void changedUpdate(DocumentEvent e) { /* not needed */ }
}

class FIFODocumentFilter extends DocumentFilter {
    private static final int MAX_LINES = 10;
    @Override public void insertString(DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attr) throws BadLocationException {
        fb.insertString(offset, text, attr);
        Element root = fb.getDocument().getDefaultRootElement();
        if (root.getElementCount() > MAX_LINES) {
            fb.remove(0, root.getElement(0).getEndOffset());
        }
    }
//     @Override public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException {
//         fb.remove(offset, length);
//     }
//     @Override public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
//         fb.replace(offset, length, text, attrs);
//     }
}

@@ -388,98 +388,15 @@
 00, 
-new ActionListener() %7B%0A        @Override public void actionPerformed(ActionEvent e) %7B%0A    
+e -%3E %7B%0A
     
@@ -433,36 +433,32 @@
 ring();%0A        
-  
-  
 textArea.append(
@@ -517,636 +517,16 @@
 s);%0A
-        %7D%0A    %7D);%0A    private final JButton start = new JButton(new AbstractAction(%22Start%22) %7B%0A        @Override public void actionPerformed(ActionEvent e) %7B%0A            if (!timer.isRunning()) %7B%0A                timer.start();%0A            %7D%0A        %7D%0A    %7D);%0A    private final JButton stop = new JButton(new AbstractAction(%22Stop%22) %7B%0A        @Override public void actionPerformed(ActionEvent e) %7B%0A            timer.stop();%0A        %7D%0A    %7D);%0A    private final JButton clr = new JButton(new AbstractAction(%22Clear%22) %7B%0A        @Override public void actionPerformed(ActionEvent e) %7B%0A            textArea.setText(%22%22);%0A        %7D%0A
     %7D);%0A
     
@@ -517,24 +517,25 @@
 s);%0A    %7D);%0A
+%0A
     public M
@@ -593,26 +593,16 @@
     
- /*
  //TEST
-%0A       
+:
  ((A
@@ -691,20 +691,8 @@
 ));%0A
-        /*/%0A
     
@@ -779,21 +779,8 @@
 ));%0A
-        //*/%0A
     
@@ -809,24 +809,409 @@
 le(false);%0A%0A
+        JButton start = new JButton(%22Start%22);%0A        start.addActionListener(e -%3E %7B%0A            if (!timer.isRunning()) %7B%0A                timer.start();%0A            %7D%0A        %7D);%0A%0A        JButton stop  = new JButton(%22Stop%22);%0A        stop.addActionListener(e -%3E timer.stop());%0A%0A        JButton clear = new JButton(%22Clear%22);%0A        clear.addActionListener(e -%3E textArea.setText(%22%22));%0A%0A
         addH
@@ -1593,24 +1593,24 @@
 lStrut(5));%0A
-
         box.
@@ -1615,16 +1615,18 @@
 x.add(cl
+ea
 r);%0A%0A   

use a lambda expression instead of an anonymous class(ActionListener)