Link to home
Start Free TrialLog in
Avatar of anonp
anonp

asked on

Make JTextField display positive# in blue and negative# in red?


Hi,

I want to customize JTextField so that it will display positive numbers in blue and negative numbers in red.  I can't simply rely on the focus events because I sometimes change the value inside the PlainDocument directly.  I was thinking about extending JTextField and customizing its behavior upon a document change event.  However, I am not sure about the details, and the code is complex to trace through.

Any ideas?  Thanks.
Avatar of ksivananth
ksivananth
Flag of United States of America image

Set a custom document. in the custom document, check the value and set appropriate color.

Siva
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Set a custom document. in the custom document, check the value and set appropriate color.

Siva