Link to home
Start Free TrialLog in
Avatar of bspotswood
bspotswood

asked on

Why would my buttons paint differently on different systems?

Okay, time for another Java newbie question ....


I've got two computers that are quite similar in their setup. Both are running Windows XP Pro SP2. Both of them have the same basic graphics setup (As far as the Windows themes and graphics/performance options). On both, I'm using the same version of Eclipse (3.0.2) with the jdk 1.5.0_03. The odd thing is, when I run a Java app on one system, it will render the buttons with a 'blue to silver to blue' vertical color fade across the buttons. On the other system, it looks more like a standard grey button face. What am I missing? Its the exact same code on both systems.


import java.awt.*;
import javax.swing.*;

public class AppMain
{
      public static void main(String[] args)
      {
            JFrame win = new JFrame("Yo");
            win.getToolkit().setDynamicLayout(true);
            win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            
            JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
            splitPane.add(new JButton("Left"));
            splitPane.add(new JButton("Right"));
            win.getContentPane().add(splitPane, BorderLayout.CENTER);

            win.pack();
            win.setLocationRelativeTo(null);
            win.setVisible(true);
      }
}

So my "Left" and "Right" buttons look different on the two systems. I'm really want to try and garuntee the color faded ones are used, but I have no idea why its rendering like that on one system and not the other. Eh?

Starting value @ 75pts.
Avatar of StillUnAware
StillUnAware
Flag of Lithuania image

compare all the values on both system like that:
on desktop, right mouse button
appearance tab
advanced button
and check the values for all Items

also here
rmb on My Computer
advanced tab
performance settings button
check if visual Effect settings are the same

I hope it helps
Avatar of bspotswood
bspotswood

ASKER

Nope, that's what I was talking about above when I said,

"Both of them have the same basic graphics setup (As far as the Windows themes and graphics/performance options). "

They're both set the same.
there mighty also be something wrong with your graphic card, as i don't see your code making the button to look like
>>'blue to silver to blue' vertical color fade

I do not even know a look and feel that fades...

open an simple explorer on both systems and compare there frames..

;-)
SOLUTION
Avatar of edwardiii
edwardiii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's what it looks like on one computer ...
http://www.addictivestuff.com/JavaPlain.jpg

And here is what it looks like on the other ...
http://www.addictivestuff.com/javawithcoloring.jpg

I guess that's more of a blue to white to blue type fade afterall.

I added a line into it to see what the look and feel was, but its the same on both systems:

System.out.println(UIManager.getLookAndFeel());

Prints:
[The Java(tm) Look and Feel - javax.swing.plaf.metal.MetalLookAndFeel]


Maybe this isn't as simple of a question as I thought. I'll go ahead and bump the points up to 200.

I'm rather unfamiliar with the Look and Feel stuff. Maybe there are other options or configuration settings that change the way it behaves? *shrugs* I don't know where to look.

I may have to end up going with Edward's suggestion and specify something. At least when I use "UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());" then it looks like the WindowsXP theme on both of the systems. Or if I disable the visual styles on the systems it looks like old Windows.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
On the system the "JavaPlain.jpg" was taken from:

C:\Documents and Settings\Brent>java -version
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)


On the sytem the coloring picture was taken from:
H:\>java -version
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)


Ahh ... but but but ... I'm launching Eclipse using the -vm option to specify the Java Virtual Machine being used. Infact, if I don't do this on the system where I'm getting the coloring, then Eclipse won't start up at all because of some missing classes in the 1.3.1 runtime environment. Here is the command I'm using on both systems when launching Eclipse:

C:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.5.0_03\bin\javaw"


Same command line on both systems is being used and both of them are installed the same.

So in Eclipse, if I open the Help menu -> About Eclipse Platform -> Click the "Configuration Details" button, I see basically the same information. There are a lot of lines, but the ones that are referring to the java VM and runtime being used read the same on both systems:


java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition
java.runtime.version=1.5.0_03-b07
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.specification.version=1.5
java.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
java.version=1.5.0_03
java.vm.info=mixed mode, sharing
java.vm.name=Java HotSpot(TM) Client VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Sun Microsystems Inc.
java.vm.version=1.5.0_03-b07

So it looks like Eclipse is starting up using the same virtual machine on both systems.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah hah! Finally an answer that lead me down the right path.

Maybe its more a problem of me being an Eclipse newbie than just Java? The machine with the 1.3 JRE was the one rendering it with the coloring. It was actually using 1.5.0_3. The machine that wasn't was using JRE 1.4.2. I was loading eclipse with the -vm option to tell it to use 1.5.0_3, but I guess that command only tells it how to load Eclipse and now how Eclipse will compile and run the applications in it? I don't know.


Anyways, I tried adding the following line to the code so I could see at runtime what version the program was using:

System.getProperties().list(System.out);

That's what proved that the program on the machine where it wasn't getting colored right was using some other VM I apparently have installed. I then started digging around in Eclipse to see if this was some sort of configuration option. Sure enough, it was. Along with your project in Eclipse, apparently you can specify the runtime environment to use. I hadn't paid any attention to this before because I really don't know what the hell I'm doing yet.

Looking at it now though, man was it obvious. Right in the text on the tree node it said "JRE System Library [j2re1.4.2_06]" ... it doesn't get more obvious, right?

I kept digging and found a way to have it search for my 1.5.0 JRE, it found it, and I set it to use that. With that JRE it looks right.

Thanks guys, I'll divvy some points up for you and Edward for the help. Thanks for really steering me in the right direction finally, StillUnAware. =)