Refactoring code duplication so the same textArea is not used in 4 different classes
Write your own class:

class MyTextArea extends JTextArea{

    private final List&lt;Foo&gt; list;

    MyTextArea(int row, int col, List&lt;Foo&gt; list) {
        super(row, col); 
        this.list = list;
        setOpaque(false);
    }

    @Override
    protected void paintComponent(Graphics g) {
        for (int i = 0; i &lt; list.size(); i++) {
            if(i == lineIndex) 
                g.setColor(Color.black);          
            g.drawRect(0, 20, 750, 20);
            //use list...
        }
        super.paintComponent(g);
    }
}