2003-11-07 01:43:03 AM
I am pretty new to java. Have been programming in C for some years, but java
and c++ both feel more "right" for me.
But even though it makes more sense in a lot of ways, I am at the beginning
of the learning curve. That said, I have an application that uses
gridBagLayout as the layout manager.
Somewhere in the code the app sets up for an image ( letter size)
to be displayed AND in a separate thread (implementing Runnable) calls a
method that will set the scroll bar to the bottom of the image. It sets up
the run method, and then calls SwingUtils.invokeLater.
The problem is this is unstable. Often, but not always, the image stays
(with scrollbar) at the top. I may have misunderstood but I tried a few
things, one being calling it as "synchronized" which at first I thought
helped but the problem returned. Also I tried changing the invokeLater to
"invokeAndWait" and still it happens.
This is inherited code, I didn't write it, and I surely have to spend more
time checking all the logic in it...but generally it seems like nothing I do
can insure that the scrollToBottom (one of the methods) works and is done
corectly before continuing.
I am not writing out the code here, so I am not necessarily asking for
someone to solve this for me, but if anyone had some similar experience and
could share general tips about this I would be interested to hear.
"In theory there is no difference between theory and practice,
but not in practice."