Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Set color

  1. #1
    Regular Coder
    Join Date
    Aug 2012
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Set color

    I have a
    Code:
    string fcolor = "GREEN"
    and I want to use a green color in
    Code:
    g.setColor(Color.BLACK);
    (java program)
    How I apply string fcolor to it?

    It took me a lots of time but it is still unresolved
    Thanks for advice

  2. #2
    Administrator VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    11,180
    Thanks
    6
    Thanked 1,343 Times in 1,312 Posts
    I’m not a Java programmer but from a quick internet search I found:

    Code:
    g.setColor(Color.FromName(fcolor));
    Does that work for you?

  3. #3
    Regular Coder
    Join Date
    Aug 2012
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts
    No, the method FromName(String) is undefined for the type Color


 

Tags for this Thread

Posting Permissions

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