Font displayFont = new Font(Font.SANS_SERIF, Font.BOLD, 18);
WindowManager.getInstance().getConsoleWindow().getTextArea().setFont(displayFont);
WindowManager.getInstance().getConsoleWindow().getTextArea().setForeground(Color.BLUE);
以上是我的代码片断,负责在单击按钮时更改我的jtextpane中文本的属性。文本正确更新变得更大和粗体,但它不会改变颜色,我不知道为什么。提前致谢。为什么我的代码没有正确更新jtextpane字体颜色?
也许setForeground不叫 – Stultuske
我不知道要尝试什么其他的方法正确的方法是什么?当我调用构造函数时setForeground似乎可以工作,但当我尝试用它来改变初始颜色时,它不起作用 – Cypher236
@ Cypher236看看我的解决方案并让我知道它是否解决了您的问题。 – user3437460