>Usually these types of problems are caused by video driver
>bugs, and usually they are DirectDraw-related. Try running
>with -Dsun.java2d.noddraw flag. If that fixes the problem,
>see if there is an updated video driver available for your
>system.
Thank you! This makes sense to me, because I already know that
I have such driver problems. I am using a somewhat historic
graphic card. It is good to know that my code is not the
cause.
My original code was even more "correct" than the one posted.
Instead of
frame.pack();
frame.setVisible( true );
I used
frame.pack();
javax.swing.SwingUtilities.invokeLater
( new java.lang.Runnable()
{ public void run(){ frame.setVisible( true ); }});
because according to the specification "frame.pack" would
start the event-dispatching thread (EDT), so it should not be
allowed for the main thread to send "setVisible( true )" then.
But everyone seems to do this, IIRC even Sun tutorials.
I never saw any other source for the second code example, so
I hope that I have not overlooked a reason not to use this.
Stefan Ram - 04 Sep 2005 17:56 GMT
>>with -Dsun.java2d.noddraw flag. If that fixes the problem,
> Thank you! This makes sense to me, because I already know that
But actually this did not help. It now seems to me that
the Windows-Programm "AllChars" has to do with it.
Several times I have now observed that an "invalid page" is
reported in "Kernel32.DLL" if the Swing-Program was terminated
while "AllChars" was activated, but that this message is not
reported when "AllChars" does not run at the time the
Swing-Application was started.
"AllChars" allows one to enter characters which are not
available from the keyboard or to reply macros. An
AllChars-DLL is loaded with a all processes started while
"AllChars" is active.
Larry Barowski - 04 Sep 2005 21:25 GMT
>>>with -Dsun.java2d.noddraw flag. If that fixes the problem,
>> Thank you! This makes sense to me, because I already know that
[quoted text clipped - 7 lines]
> reported when "AllChars" does not run at the time the
> Swing-Application was started.
Try a different version of Java.
Stefan Ram - 04 Sep 2005 22:54 GMT
>Try a different version of Java.
I now have written a wrapper to start the JVM, while AllChars
is deactivated. A batch file contains code similar to:
perl terminate_AllChars.pl
java SwingApplication
AllChars.exe
Larry Barowski - 04 Sep 2005 21:25 GMT
> My original code was even more "correct" than the one posted.
>
[quoted text clipped - 16 lines]
> I never saw any other source for the second code example, so
> I hope that I have not overlooked a reason not to use this.
Yes, you should always do all gui operations on the EDT
to avoid unexpected exceptions at startup. And any
problems are likely to be timing-related, so just because
code that doesn't do this works on your system 999
times doesn't mean it won't fail the 1000th time or every
time on another system.
When the jvm or your system crashes though, then it
can not be the fault of your Java code. It's either a Java
bug or a system problem.
Roedy Green - 07 Sep 2005 11:30 GMT
>frame.pack();
>javax.swing.SwingUtilities.invokeLater
[quoted text clipped - 4 lines]
> start the event-dispatching thread (EDT), so it should not be
> allowed for the main thread to send "setVisible( true )" then.
there are a few methods that are thread safe that don't need
invokeLater
There are a few exceptions to this general rule, most notably it is
safe to call repaint and revalidate, JTextComponent.setText and
JTextArea.append from any thread.
I vaguely recall reading setVisible is also safe, but I can't find the
reference.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.