Here is a working example:
import javax.swing.*;
import java.awt.*;
public class ScratchSpace {
public static void main(String[] args) {
JFrame frame = new JFrame("");
final MyTextPane textPane = new MyTextPane();
frame.add(textPane);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
private static class MyTextPane extends JTextPane {
public MyTextPane() {
super();
setText("Hello World");
setOpaque(false);
setBackground(new Color(0,0,0,0));
}
@Override
protected void paintComponent(Graphics g) {
g.setColor(Color.GREEN);
g.fillRect(0, 0, getWidth(), getHeight());
super.paintComponent(g);
}
}
}
It is important to note:
, "Filthy Rich Clients", , Swing .