jabir khan
jabir khan

Reputation: 1

How to under-line selected text in JtextArea

I want to make selected text of jtextarea underline while clicking a spicified button. this task I have accomplish in jtextpane but I need it in jtextarea any suggestions please.

Upvotes: 0

Views: 372

Answers (2)

camickr
camickr

Reputation: 324128

I want to make selected text of jtextarea underline

You can add a Highlighter to the text area and use a custom Painter to highlight the text. The default painter paints the entire background of the highlighted text, but you can customize the Painter to do whatever you want.

Check out Rectangle Painter for a couple examples of creating your own custom Painter.

Upvotes: 0

log_0
log_0

Reputation: 878

Use a JTextPane (or JEditorPane), where you can use HTML tags to accomplish that.

The text of a JTextArea cannot be formatted in parts, as indicated here, for example:

A JTextArea is a multi-line area that displays plain text.

Upvotes: 1

Related Questions