JDialog doesn't draw

I'm new to java, but I would think this is pretty straight forward. I am showing a JDialog for user input when importing data from a text file, but the dialog does not paint properly on other computers.

On my computer, if I run the program from NetBeans or from the command line, the dialog is displayed correctly. If I run the program on the computer it was supposed to run on, then the inside of the dialog won't be drawn - all I can see is the border of the dialog and then the screen behind which the controls are. This computer is running XPSP2 and jre6 update 11.

Does anyone know what could go wrong?

TIA

+1


source to share


4 answers


We need to make sure your code is confident, but most likely you are importing into the UI thread , from some listener code - since you are using the UI thread, no events are processed until you return from the listener.



The solution is to start a new import thread and then fire events to update the GUI.

+1


source


Are you doing all your Swing work in the Thread Dispatch Thread ? If so, are you sure that you are not blocking this thread, or doing something slow on it?



0


source


Run the program through a command terminal so you can see that your program is throwing any exceptions.

The command would be: java -jar pathtoyourjar.jar

0


source


The code works in one place, but not in another. Computers are not magic. Therefore, there must be some difference between the two computers. Code is GUI Swing code. The three most likely differences are:

  • Various video devices
  • Various codes (possibly JRE libraries)
  • Different Swing Look and Feel (possibly caused by different OS)

If something about connecting Java to video hardware on two machines is different, give it a try and find out what. Do your machine and target machine have the latest video drivers, etc.? Does the target machine have two monitors, or is there some other difference in video hardware that could cause different code to execute?

Differences between the two computers, such as the JRE or OS, can lead to different code execution. You told us the JRE and OS for the target machine: what about your machine? Can you find a third machine or install another JRE so we know it's a machine or a JRE?

You can have different Swing Looks and Feels on two machines. Try with a different Look and Feel.

UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());

      

Just to mention that the problem is probably with your code somewhere, and the error is more likely to be in your code than in the Swing libraries, but that at least can help you figure out why everything works on one machine and not another.

0


source







All Articles