Results 1 to 2 of 2
  1. #1
    boostshock is offline Member
    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Default Change color with hex code?

    I am trying to write a code to change the color with a hex code. Actually I want to add my own colors instead of "black" "red" and so on. So if I write skyblue it should use "#3398F0".
    I am working on the example project of BlueJ. If you use this program you should have it too.

    Take a look at the picture. How can I add some different colors?


    Thanks!

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

    Default Re: Change color with hex code?

    Take a look at the constructors of java.awt.Color that take int parameters. Also Integer methods that take a String and an int radix.

    Alternatively, you can hard-code a Map<String, Color> to do the lookup.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. How to change background color
    By Jeffrey4u in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 10-22-2011, 09:32 AM
  2. PLEASE HELP! how do i change the color of a pattern?
    By armedrabbit in forum New To Java
    Replies: 9
    Last Post: 04-20-2011, 09:51 PM
  3. Can't change the color of a button...
    By mrbeast87 in forum AWT / Swing
    Replies: 5
    Last Post: 11-16-2010, 10:22 PM
  4. Change color of a region
    By sky in forum AWT / Swing
    Replies: 5
    Last Post: 11-24-2009, 04:47 PM
  5. my code doesn't change background color
    By javanoobita in forum New To Java
    Replies: 5
    Last Post: 02-22-2009, 05:30 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
  •