What on earth does screen = JTextPane() { . . . mean? Have you got a method of that name or are you trying to create an anonymous class? In either case it looks as though you have a compiler error in it.
Campbell Ritchie wrote:What on earth does screen = JTextPane() { . . . mean? Have you got a method of that name or are you trying to create an anonymous class? In either case it looks as though you have a compiler error in it.
Anyway, one solution is to put the JTextPane into a JScrollPane and set the gradient of the JViewport that holds the JTextPane. If you do this be sure to set the JTextPane's opaque property to false. Oh, and you probably want to avoid using null layout and setBounds.
pete's solution is good, but "fixes" the gradient background i.e. the background gradient won't scroll with the text pane.
It's sufficient to setOpaque(false) and paint the text pane's background before invoking the super implementation.To the OP: note that constructing a GradientPaint is computationally expensive and you are likely to see a surge in CU use during periods of frequent repainting, or even a slowdown and flickering/jerks on an older, slow computer.
luck, db
There are no new questions, but there may be new answers.