JTextPane Background Color

后端 未结 1 909
南笙
南笙 2021-02-09 02:48

I am making a text-based game where the user inputs text to solve the game. I decided to use java swing to display the text, and I want to have the background of the textPane to

相关标签:
1条回答
  • 2021-02-09 03:19

    You may have an issue with Nimbus not respecting the background color settings. Try this to override the color:

      JEditorPane area = new JEditorPane();
    
      Color bgColor = Color.BLACK;
      UIDefaults defaults = new UIDefaults();
      defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
      area.putClientProperty("Nimbus.Overrides", defaults);
      area.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
      area.setBackground(bgColor);
    
    0 讨论(0)
提交回复
热议问题