peparsons
asked on
JButton setBackgroundColor doesn't work with Windows XP Look and Feel
My swing application uses JButtons with different background colours. In my application the colour conveys important information and is necessary.
When the code runs under Windows 2000, it works fine, but as soon as it runs under XP, all the buttons appear the same colour under the new XP Look and Feel. The setBackgroundColour function does nothing.
I've tried running some code I found on the Java website as a work-aroung, but it doesn't support HTML on the buttons (which I also require).
The code I tried I found here:
http://forum.java.sun.com/thread.jsp?forum=57&thread=430926
Anyone else have any suggestions?
When the code runs under Windows 2000, it works fine, but as soon as it runs under XP, all the buttons appear the same colour under the new XP Look and Feel. The setBackgroundColour function does nothing.
I've tried running some code I found on the Java website as a work-aroung, but it doesn't support HTML on the buttons (which I also require).
The code I tried I found here:
http://forum.java.sun.com/thread.jsp?forum=57&thread=430926
Anyone else have any suggestions?
ASKER
It would work with any of the other standard java look and feels, but I'm looking to write a Windows application, with the standard windows look and feel. Alos, the end users will be using both Windows 2000 and XP.
Perparson,
Can you paste the relevant code portions?
I have used the .setBackgroundColor in my application and it worked for XP clients, thats why I am asking...
Aviad.
Oh, also note that I used J2SE 5.0, I'll try to run it with J2SE 1.4.2 (that I noticed this is what you used, in the thread you supplied).
Aviad.
You could try jGoodies Looks (http://www.jgoodies.com/freeware/looks/index.html)
I quote:
:: JGoodies Windows L&F :: Precise Emulation ::
The JGoodies Windows look&feel focuses on a precise emulation on Windows 95/98/NT/ME/2000 in the following areas: menus, icons, colors, borders, fonts, font sizes, insets, and widget dimensions. It honors the screen resolution (96dpi vs. 120 dpi) to adjust sizes, insets, and widget dimensions.
I quote:
:: JGoodies Windows L&F :: Precise Emulation ::
The JGoodies Windows look&feel focuses on a precise emulation on Windows 95/98/NT/ME/2000 in the following areas: menus, icons, colors, borders, fonts, font sizes, insets, and widget dimensions. It honors the screen resolution (96dpi vs. 120 dpi) to adjust sizes, insets, and widget dimensions.
peparsons;
That would be the problem of windows xp. Since the default look and feel of windows looks like metal its not available to do it in Java.
we can change it if we change the settings of windows xp's apperance to classic but w/o changing it to classic there's no other way.
Unless you make your own customize look and feel for Java.
That would be the problem of windows xp. Since the default look and feel of windows looks like metal its not available to do it in Java.
we can change it if we change the settings of windows xp's apperance to classic but w/o changing it to classic there's no other way.
Unless you make your own customize look and feel for Java.
I hope my solution did not give you a headache but I would say that it is the fact.
Using images for your buttons will give you full control over there appearance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm afraid the simplest solution is to put a coloured image (with text) on your button(s).
If you want to mark (e.g.) a RED button, that's surely the way to go.
<*>
If you want to mark (e.g.) a RED button, that's surely the way to go.
<*>
gL,
[r.D]