Results 1 to 7 of 7
- 10-17-2008, 11:14 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 39
- Rep Power
- 0
Addin color to text, probs really simply, please help!!!
Hi all, im new to Java and would like to know how to add color to text, please help?
public class greetingApp extends JApplet {
public static void main(String args[]) {
System.out.println("Hi Peter" foreground.color.blue);
System.out.println("from Stuart to Peter");
System.out.println(" University");
}
}
- 10-17-2008, 11:36 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
You can't. Not in System.out calls (or any other PrintWriter/PrintStream calls). Which a quick look into the API would have told you.
Which you means you can't when printing to the console. If you have a JLabel, you can use some simple HTML markup.
- 10-17-2008, 11:52 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 39
- Rep Power
- 0
Ok thank, how do us suggest i write it instead??
public class greetingApp extends JApplet {
public static void main(String args[]) {
System.out.println("from Stuart to Peter");
}
}
- 10-17-2008, 12:32 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
That depends on what it is you actually want to acheive.
- 10-17-2008, 02:40 PM #5
A comment on your code as shown.
the main method has no special usage in an applet as it does in a normal app.
Are you writing an applet or a app?
- 10-17-2008, 05:07 PM #6
Member
- Join Date
- Oct 2008
- Posts
- 39
- Rep Power
- 0
ITs an applet.
- 10-17-2008, 06:11 PM #7
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
probs
By amith in forum Java 2DReplies: 1Last Post: 06-29-2008, 09:13 PM -
How to use TextAttribute class to change color and font of a text
By Java Tip in forum java.awtReplies: 0Last Post: 06-25-2008, 10:33 AM -
A few java probs
By Mezzie in forum New To JavaReplies: 4Last Post: 06-11-2008, 07:59 AM -
Changing the color of text
By Lang in forum New To JavaReplies: 1Last Post: 11-04-2007, 09:51 AM -
Simply output the result to a text file.
By silvia in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks