Reputation:
I'm new to java but I would have thought this was pretty straight foward. I display a JDialog for user input when importing data from a text file but the dialog isn't being painted properly on other computers.
On my computer if I run the program from within NetBeans or from the command prompt then the dialog displays properly. If I run the program on the computer it's supposed to be running on then the inside of the dialog isn't painted - all I see is the border of the dialog then the screen behind it where the controls should be. This computer is running XPSP2 and jre6 update 11.
Does anyone know what could be going wrong?
TIA
Upvotes: 1
Views: 1750
Reputation: 44203
The code works in one place but not in another. Computers aren't magic. So there must be some difference between the two computers. The code is Swing GUI code. The three most likely differences are:
If something about the Java connection to the video hardware is different on the two machines, try and find out what. Do your machine and the target machine both have the latest video drivers etc? Does the target machine have two monitors, or some other difference in video hardware that might cause different code to be executing?
Differences between the two computers eg JRE or OS might cause different code to be executing. You have told us the JRE and OS for the target machine: what about for your machine? Can you find a third machine, or install another JRE so we know if it is the machine or the JRE?
You might have different Swing Look and Feel's on the two machines. Try with a different Look and Feel.
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
Just to mention the problem is probably with your code somewhere, and the bug is more likely to be your code than in the Swing Libraries, but this at least might help you work out why everything works on one machine and not on another.
Upvotes: 0
Reputation: 4785
Run the program through a command terminal so you can see if any exceptions are being thrown by your program.
The command will be: java -jar pathtoyourjar.jar
Upvotes: 0
Reputation: 64064
We need to see your code to be sure, but it's most likely you are performing the import on the UI thread, from within some listener code - since you are using the UI thread, no events are processed until you return from the listener.
The solution is to launch a new thread to do the import and then have it trigger events to update the GUI.
Upvotes: 1
Reputation: 6940
Are you doing all your Swing-related work in the Event Dispatch Thread? If so, are you sure you are not blocking this thread, or doing something slow in it?
Upvotes: 0