kap
kap

Reputation: 11

JList strike through

I have a list of data in a JList component in my GUI.

I would like to know if there is a method that i can call on the list element(s) to strike through a particular element in the list. I would like to draw a line through the element to appear as if that element is canceled.

I want a similar thing like the strike through functionality in Microsoft Word document whereby a line i drawn through the text.

thanks for your help

Upvotes: 1

Views: 683

Answers (2)

Mark
Mark

Reputation: 29139

JIDE Common Layer has a StyledListCellRenderer that can be used to provide this functionality.

Upvotes: 1

Mike
Mike

Reputation: 1481

You can apply html formating to each element of a list. Therefore if you know what element you want struck through you can modify the string held by that element as such:

<html><strike>this text will be struck through</strike></html>

Edit: I should note that I haven't tested this so if the strike tag isn't supported in Java try just s. One of those should work

Upvotes: 2

Related Questions