azcalv408
asked on
how do I add colors to strings
Hi,
I'm new to Java. Can someone tell me how I can change a string to different colors ? Thanks!
ex: String s = "Print this line in red";
I'm new to Java. Can someone tell me how I can change a string to different colors ? Thanks!
ex: String s = "Print this line in red";
It's not the actual string that has the color property. It's the container in which you present the string. Where are you going to show it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i want to show it within a Jpanel. thanks
Add the JEditorPane to the JPanel
Or add a JLabel to the JPanel:
JLabel label = new JLabel();
JPanel.add(label);
label.setForeground(Color. RED);
label.setText(theString);
JLabel label = new JLabel();
JPanel.add(label);
label.setForeground(Color.
label.setText(theString);
8-)
Almost all JAVA SWING controls (labels, buttons ...) can display HTML texts.
;JOOP!
;JOOP!