Is it possible to change the color of a text in a text field?I am trying to build an interpreter, so I was wondering on how would you change the color of the text in real time. For example the word I enter in the text field is:
printf("hi");
The word printf
becomes green after a few seconds.
Is it possible?
You have to use JEditorPane / JTextPane instead of JTextField and also you can draw the text/string by overriding the paintComponent method.
Try this: