Results 1 to 7 of 7
  1. #1
    hung_tyh is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default color text in standalone???

    Hi, I am new in Java.
    Is it possible to make a color text in standalone adn how?
    Is it necessary to make it a applet if I want to have a color on the text?
    Thanks for answering.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Bit confusing that what you are talking about standalone?

    No need to create Applets always to have colored text. You can do the same thin on Swing application as well.

    Here is a simple way to have colored text on a JLabel.

    Java Code:
    JLebal textLabel = new JLabel("Colored text");
    textLabel.setFont(new Font("Arial", Font.PLAIN, 20));
    textLabel.setForeground(Color.GREEN);

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Standalone = Command Prompt?

    I think the OP means if he/she can change the color of the text when printing to the command prompt. hhhmmm... directly using Java methods? ...probably not. Since the command prompt is governed by the OS, you would have to tell the OS to do that and I'm not sure how to do that.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Standalone = Command Prompt?
    I've never comes with such a thing before. I mean such a word refereeing for the command prompt.

  5. #5
    hung_tyh is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Bit confusing that what you are talking about standalone?

    No need to create Applets always to have colored text. You can do the same thin on Swing application as well.

    Here is a simple way to have colored text on a JLabel.

    Java Code:
    JLebal textLabel = new JLabel("Colored text");
    textLabel.setFont(new Font("Arial", Font.PLAIN, 20));
    textLabel.setForeground(Color.GREEN);

    can u give me a more detail coding coz i reli dun get it......
    Can u give me an example like outputing a sentence"HELLO!"?
    thx a lot & Merry X'mas

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by hung_tyh View Post
    can u give me a more detail coding coz i reli dun get it......
    Can u give me an example like outputing a sentence"HELLO!"?
    thx a lot & Merry X'mas
    Yes I can help you to solve this problem. But here not clear what you really looking. What you mean by standalone? Seems that you want to have colored text on the command prompt, right?

    If yes, please read CJSLMANs' last post.

Similar Threads

  1. Text color in disabled componentes
    By saul_2110 in forum AWT / Swing
    Replies: 8
    Last Post: 12-13-2008, 05:37 AM
  2. Replies: 6
    Last Post: 10-17-2008, 06:11 PM
  3. Replies: 0
    Last Post: 06-25-2008, 10:33 AM
  4. howto make a standalone application?
    By Jerre in forum New To Java
    Replies: 4
    Last Post: 06-08-2008, 09:58 AM
  5. Changing the color of text
    By Lang in forum New To Java
    Replies: 1
    Last Post: 11-04-2007, 09:51 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
  •