Skip to content Skip to sidebar Skip to footer

Error With Making Text Bold And Colored In JTextPane

I am trying to create a text editor using a JTextPane that outputs the text as HTML. I want to include the options to bold, color and align the text. I am having an issue with chan

Solution 1:

here is some of my code that makes the text bold:

Don't know the context of how that code is used. But I would say a better way to do this is to just use the default Bold Action found in the StyledEditorKit.

Read the Swing tutorial on Text Component Features for a simple example of an editor. The example uses a JTextPane, but the concepts for creating the menu items will be the same.


Solution 2:

Is there an action that allows you to "unbold" text?

Create and apply a suitable SimpleAttributeSet such as normal, seen here.

image


Post a Comment for "Error With Making Text Bold And Colored In JTextPane"