Windows XP Theme colours with java.awt
Hi,
I am extending a legacy AWT project and want to make it more XP like. Mostly its going OK, but I am having trouble picking up colours from the current Windows XP Theme. I am able to get the colour of the 2D borders by creating Swing components in memory and then using the following code...
try
{
LookAndFeel oldLF = UIManager.getLookAndFeel();
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JTextField jtf =new JTextField();
if (jtf.getBorder()instanceof javax.swing.border.LineBorder)
m_borderCol = ((javax.swing.border.LineBorder)jtf.getBorder()).getLineColor();
UIManager.setLookAndFeel(oldLF);
}
catch (Exception e){ e.printStackTrace();}
But I can't seem to get access to the colour used for combo box buttons, scroll bars (i.e. in standard Windows XP Theme the light blue colour). I've tried using the UIManager.getColor() method e.g.
m_combo_buttonCol = UIManager.getColor("ComboBox.buttonBackground");
But this seems to return the standard "grey" colour scheme values.
All the code is ran inside IE in an Applet and is using the JRE 1.4.2 08 runtime (developed using IBM's RAD).
If anyone can tell be how to get these colours I would be most grateful!
Thanks
Rich
[1665 byte] By [
sanx] at [2007-11-25 20:39:28]

# 2
> Hi,
>
> I am extending a legacy AWT project and want to make
> it more XP like. Mostly its going OK, but I am having
> trouble picking up colours from the current Windows
> XP Theme. I am able to get the colour of the 2D
> borders by creating Swing components in memory and
> then using the following code...
>
>
> try
> {
> LookAndFeel oldLF =
> Feel oldLF = UIManager.getLookAndFeel();
>
>
>
>
>
>
>
>
>
>
>
> UIManager.setLookAndFeel(UIManager.getSystemLookAndFe
> elClassName());
>
> JTextField jtf = new JTextField();
>
> if (jtf.getBorder() instanceof
> ) instanceof javax.swing.border.LineBorder)
> m_borderCol =
> m_borderCol =
> =
> ((javax.swing.border.LineBorder)jtf.getBorder()).getLi
> neColor();
>
> UIManager.setLookAndFeel(oldLF);
> }
> catch (Exception e) { e.printStackTrace(); }
> ace(); }
>
>
> But I can't seem to get access to the colour used for
> combo box buttons, scroll bars (i.e. in standard
> Windows XP Theme the light blue colour). I've tried
> using the UIManager.getColor() method e.g.
>
> [code]m_combo_buttonCol =
> UIManager.getColor("ComboBox.buttonBackground");[/code
> ]
>
> But this seems to return the standard "grey" colour
> scheme values.
>
> All the code is ran inside IE in an Applet and is
> using the JRE 1.4.2 08 runtime (developed using IBM's
> RAD).
>
> If anyone can tell be how to get these colours I
> would be most grateful!
>
> Thanks
> Rich
Love mean never having to say your sorry ..