Background « JTextPane « Java Swing Q&A





1. Changing the background color of a paragraph in JTextPane (Java Swing)    stackoverflow.com

Is it possible to change the background color of a paragraph in Java Swing? I tried to set it using the setParagraphAttributes method (code below) but doesn't seem to work.

  ...

2. Background Image in JTextPane    stackoverflow.com

How do I set a background image to a JTextPane - some sort of a watermark. I tried this option - creating a child class of JTextPane and use ...

3. Issue with JTextPane with background image and clipping rectangle    stackoverflow.com

I have a problem with Swing that I just don't find the reason for. I have a JTextPane that has been extended to show a background image. This can be either ...

4. Gradient Background for JTextPane    coderanch.com

import java.awt.*; import javax.swing.*; public class TextPaneGradient { private static void createAndShowUI() { JTextPane screen = new JTextPane(); screen.setOpaque(false); JViewport viewport = new JViewport(){ public void paintComponent(Graphics og) { super.paintComponent(og); Graphics2D g = (Graphics2D) og; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); GradientPaint gradient = new GradientPaint(0, 0, Color.gray, 0, getHeight(), Color.white, true); g.setPaint(gradient); g.fillRoundRect(0, 0, getWidth(), getHeight(), 30, 30); } }; viewport.setPreferredSize(new Dimension(400, 300)); viewport.add(screen); ...