Help Regarding Background color(Java)

Discussion in 'Mac Programming' started by Alvinkiang, Apr 24, 2006.

  1. Alvinkiang macrumors newbie

    Apr 24, 2006
    I created a small Program to read in a XML File and to display the items on a Jpanel... All is very successful except that i am not sure how to change the Current Background Color to the Color i read From the XML file. Can Relevant Examples BY any one?:confused:
  2. mrichmon macrumors 6502a

    Jun 17, 2003
    The background color of what?

    Certain parts of the Java UI on OS X using the default look and feel cannot be changed. For example, the background color on buttons cannot be altered in the default look and feel for OS X. You can change from the default look and feel to the cross-platform look and feel if you want. See the code example in the following post to find out how to manage the look and feel used
  3. Alvinkiang thread starter macrumors newbie

    Apr 24, 2006
    actually what i meant was changing the backGround color of the Jpanel accordingly to the XML file color:




    Is there any code relevant to help? i am unsure of the coding for this...
  4. gekko513 macrumors 603


    Oct 16, 2003
    #import java.util.*;
    #import java.awt.*;
    // in class variable declarations
    HashMap colorMap;
    // in a constructor or initializer
    colorMap = new HashMap();
    colorMap.put("cyan", new Color(0, 255, 255));
    // and so forth
    // in the xml parser
    add error checking as you see fit

Share This Page