I am trying to write text in a list box and at times I want to show a "strikethrough" on the text. However, it isn't clear to me how it can be done.
 
I found that Fonts have TextAttribute maps and one of the TextAttributes is STRIKETHROUGH, which can be set on. So I was trying to construct a Font with with that attribute but I don't understand how to do that. TextAttribute's constructor is protected so I assume they are always created for you by a factory or an Object you talk to, like the Font.
 
The following is my lame attempt to get a Font with TextAttribute.STRIKETHROUGH set to true. It doesn't work.
 
    Font f = new Font("MonoSpaced", Font.BOLD, 20);
    Map m = f.getAttributes();
    // Trying here to add a strikethrough attribute for a new map.
    m.put(java.awt.font.TextAttribute.STRIKETHROUGH, new Boolean(true));
    // Create a new font with (supposedly) a newly added strikethrough attribute.
    f = new Font(m); 
    // The component acts like it just got the original new Font("MonoSpaced", Font.BOLD, 20);
    // transactionList is a JList derrived class.
    transactionList.setFont(f);
 
If anyone knows of an example, the correct why to do this, or an explanation in a document somewhere, I would greatly appreciate it. Thanks in advance for any help.
 

Doal Miller

Fulcra

email: [EMAIL PROTECTED]

voice: (858) 874-7162

fax: (858) 571-1208

 

Reply via email to