Vision Numeric Text Field underlined text

Usually when I want underlining in a label, I resort to using the HTML tag <U>, however I can’t do that for the numeric text field. Is there another way I can do this?

Got it:

if event.propertyName in ('componentRunning'):
	from java.util import HashMap
	from java.awt.font import TextAttribute
	
	fontAttributes = HashMap()
	fontAttributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON)
	
	obj = event.source
	obj.setFont(obj.getFont().deriveFont(fontAttributes))

Edit: worth noting that to turn it off, there’s no corresponding “UNDERLINE_OFF”. Simply set it to -1.

7 Likes