![]() ![]() Take a look at the DefaultHighlightPainter inner class of DefaultHighlighter. Let me know if you need more source code to understand the question. P.setDocument(kit.createDefaultDocument()) ![]() The JTextPane is set up as with content type HTML and uses the HTMLEditorKit: p=new JTextPane() I use the following code to set up the JTextPane and button that changes the selected text to red: JButton redButton = new JButton(new StyledEditorKit.ForegroundAction("red", Color.RED)) Is there a way to have selected text show up as it's actual color? Or like the way it works in Word where it's not the actual color of the text, but when text of different colors are selected they show up as different colors even when selected. I tried using setSelectedTextColor to change the color of the selected text, but that doesn't work since that changes the text to red anytime text is selected afterwards. But when the user selects the text, then chooses the option to change the color (say, to red) the text does not appear as red until the text is unselected. E) When finished, you can close Edit Colors and Paint. D) The Red Green Blue numbers for the color will be at the bottom right corner of the Edit Colors dialog. C) Select a color, and adjust the color to what you want. ![]() I am creating a text editor using a JTextPane that allows the user to change the color of selected text. B) Click/tap on the Edit colors button in the Home tab. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |