我怀疑你需要子类化JTextArea并覆盖paintComponent()方法,首先绘制背景图像并调用super.paintComponent()渲染文本:
public void paintComponent (Graphics g) {
g.drawImage(watermark, 0, 0, this);
super.paintComponent(g);
}
Run Code Online (Sandbox Code Playgroud)
编辑:正如camickr所指出的,a JTextArea是不透明的,所以你的子类需要通过调用来改变它setOpaque(false).