Adding a background to a JTextArea

Make sure the opaqueness property of your JTextArea component is false. You can then override the paintComponent method that draws the background image and calls super.paintComponent. Here’s an example:

import javax.swing.*;
import java.awt.*;
 
public class Main {
   public static void main(String args[]) {
      JFrame frame = new JFrame("JTextArea Background Demonstration");
      final ImageIcon imageIcon = new ImageIcon("esuslogo.gif");
 
      JTextArea textArea = new JTextArea() {
         Image image = imageIcon.getImage();
         { 
            setOpaque(false);
            image = image.getScaledInstance(400, 300, Image.SCALE_DEFAULT);
         }
         public void paintComponent (Graphics g) {
            g.drawImage(image, 0, 0, this);
            setForeground(Color.blue);
            super.paintComponent(g);
         }
      };
      textArea.setFont(new Font("Helvetica", Font.BOLD, 16));
 
      frame.getContentPane().add(BorderLayout.CENTER, new JScrollPane(textArea));
      frame.setDefaultCloseOperation(3);
      frame.setSize(400, 300);
      frame.setVisible(true);
      frame.setResizable(false);
   }
}