Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Alvinkiang

macrumors newbie
Original poster
Apr 24, 2006
14
0
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:
Thanks
 

mrichmon

macrumors 6502a
Jun 17, 2003
873
3
Alvinkiang said:
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:
Thanks

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

https://forums.macrumors.com/showthread.php?p=2156406#post2156406
 

Alvinkiang

macrumors newbie
Original poster
Apr 24, 2006
14
0
mrichmon said:
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

https://forums.macrumors.com/showthread.php?p=2156406#post2156406

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

<Color>

<code>cyan</code>

</Color>

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

gekko513

macrumors 603
Oct 16, 2003
6,301
1
Code:
#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
panel.setBackground((Color)colorMap.get(colorString));
add error checking as you see fit
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.