Search code examples
javaswingbackgroundjtextpane

How can I change the background color of an uneditable JTextPane in Java?


I have a JTextPane that haspane.setEditable(false) which forces it to have a 'greyed-out' background color.

After trying setBackground(Color.WHITE) (which doesn't work), I tried looking around the net for an answer but not managed to find one yet.

Can anyone help me on this one please?


Solution

  • I found out what it was - it was because I had pane.setOpaque(false), I couldn't change the background color without first either removing this or changing it to true.

    setBackground(Color.white) worked after altering this.