How to compile it: g.drawString("this is something I want people to <p color="#00FF00">NOTICE</p>", x, y); as '"' is a special character that we must avoid with \
You have added to Graphics2D but are not using it (does not apply to the problem, but can cause anomalies).
It should be:
Graphics2D g2 = (Graphics2D) g; g2.drawString("this is something I want people to <p color=\"#00FF00\">NOTICE</p>", x, y);
to add color, just call setColor(Color c) on the Graphic object:
g2.setColor(Color.GREEN);
However, this will cause the entire line to be drawn in green, if you want only the parts to be green, use JLabel to support HTML (before HTML3.2):
JLabel label = new JLabel("<html>this is something I want people to <p color=\"#00FF00\">NOTICE</p></html>");
full example:

NB . As you can see, the notification is in its own line, because of the paragraph tag, rather use the font tag to get it on one line:

import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JLabel; public class Test { public Test() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("<html>this is something I want people to <p color=\"#00FF00\">NOTICE</p></html>");
source share