Results 1 to 7 of 7
  1. #1
    soc86 is offline Member
    Join Date
    Oct 2008
    Posts
    39
    Rep Power
    0

    Default 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");


    }
    }

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    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.

  3. #3
    soc86 is offline Member
    Join Date
    Oct 2008
    Posts
    39
    Rep Power
    0

    Smile

    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");


    }
    }

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    That depends on what it is you actually want to acheive.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,556
    Rep Power
    23

    Default

    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?

  6. #6
    soc86 is offline Member
    Join Date
    Oct 2008
    Posts
    39
    Rep Power
    0

    Default

    ITs an applet.

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

Similar Threads

  1. probs
    By amith in forum Java 2D
    Replies: 1
    Last Post: 06-29-2008, 09:13 PM
  2. Replies: 0
    Last Post: 06-25-2008, 10:33 AM
  3. A few java probs
    By Mezzie in forum New To Java
    Replies: 4
    Last Post: 06-11-2008, 07:59 AM
  4. Changing the color of text
    By Lang in forum New To Java
    Replies: 1
    Last Post: 11-04-2007, 09:51 AM
  5. Simply output the result to a text file.
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •