[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

JButton setBackgroundColor doesn't work with Windows XP Look and Feel

Posted on 2004-11-02
10
Medium Priority
?
445 Views
Last Modified: 2013-11-23
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?
0
Comment
Question by:peparsons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12474384
Have you tried changing the look and feel to one, other than Windows? (or must it be windows?)

gL,
[r.D]
0
 

Author Comment

by:peparsons
ID: 12474408
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.
0
 
LVL 3

Expert Comment

by:aviadbd
ID: 12475300

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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:aviadbd
ID: 12475306

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.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12478508
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.
0
 
LVL 15

Expert Comment

by:Javatm
ID: 12478564
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.
0
 
LVL 15

Expert Comment

by:Javatm
ID: 12478593
I hope my solution did not give you a headache but I would say that it is the fact.
0
 
LVL 92

Expert Comment

by:objects
ID: 12478613
Using images for your buttons will give you full control over there appearance.
0
 
LVL 15

Accepted Solution

by:
Javatm earned 1500 total points
ID: 12478618
However you can still tweak the look and feel of the button by customizing the whole button its self.
You can create your own graphics and use it as the button.

1. Customize your buttons by designing the image.
2. Use the codes bellow for customizing it :

  JButton button = new JButton(new ImageIcon("x1.gif"));
  button.setPressedIcon(new ImageIcon("x2.gif"));
  button.setRolloverIcon(new ImageIcon("x3.gif"));
  button.setDisabledIcon(new ImageIcon("x1.gif"));
  button.setFocusPainted(false);
  button.setBorderPainted(false);
  button.setContentAreaFilled(false);
  button.setMargin(new Insets(0,0,0,0));

Hope that helps . . .
Javatm


0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12480466
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.

<*>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This video teaches viewers about errors in exception handling.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question