简体   繁体   English

如何更改 JEditorPane 中选定文本的颜色?

[英]How to change the color of a selected text in a JEditorPane?

I am currently developing a program that allows you to change the color of a selected text from a JEditorPane , using setSelectedTextColor (Color.red) , but it only temporarily changes the text when I run it with the cursor.我目前正在开发一个程序,该程序允许您使用setSelectedTextColor (Color.red)JEditorPane更改选定文本的颜色,但当我使用 cursor 运行它时,它只会临时更改文本。

I would like to know how I can set it or change it, as well as the setForeground我想知道如何设置或更改它,以及setForeground

Maybe this post can help you: Changing color of selected text in jTextPane也许这篇文章可以帮助您: 更改 jTextPane 中选定文本的颜色

This use jTextPane instead of jEditorPane, which I've searched for and says that supports color changes better than jEditorPane.这使用 jTextPane 而不是 jEditorPane,我已经搜索并说它比 jEditorPane 更好地支持颜色更改。

If that doesn't works, please search in Google for your question and if you find it, we will appreciate you post it here.如果这不起作用,请在 Google 中搜索您的问题,如果找到,我们将感谢您在此处发布。 Thanks.谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM