Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

SwingUtilities.invokeLater(doFinished); not working on MAc

Thread view: 
jdilip@gmail.com - 24 Feb 2006 14:25 GMT
Hi
SwingUtilities.invokeLater(doFinished); line of SwingWorker class
doesnot execute on mac pc. The same code is working perfectly on
Windows 2000 and XP. After adding many System.out.Println().. i found
that my execution halts at the SwingUtilities.invokeLater(doFinished);
line. The application really hangs there. I have top force quit the
application. Note here i do not have any Swing GUI in picture. I have
certain class methods to access db and forward the data to the calling
app. My app used C++ and JNI to call my java methods. Please someone
tell me whether ther eis soome problem of the SwingWorker clas on mac
or some other thing.
Thanks
Dilip Jain
Thomas Hawtin - 24 Feb 2006 15:16 GMT
> SwingUtilities.invokeLater(doFinished); line of SwingWorker class
> doesnot execute on mac pc. The same code is working perfectly on
[quoted text clipped - 6 lines]
> tell me whether ther eis soome problem of the SwingWorker clas on mac
> or some other thing.

There are many versions of SwingWorker.

It sounds like a deadlock of some form. If you get a stack dump it may
show up. I don't know the Mac way of doing things. On Windows it would
be Ctrl-Break from the console. On Linux Ctrl-\ from the console, or use
jstack <process-id>.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Steve W. Jackson - 24 Feb 2006 16:37 GMT
> > SwingUtilities.invokeLater(doFinished); line of SwingWorker class
> > doesnot execute on mac pc. The same code is working perfectly on
[quoted text clipped - 15 lines]
>
> Tom Hawtin

There is no "Mac way" in Java, only Apple's JVM that is fully compliant
with Sun's JLS.

While I haven't got a copy of SwingWorker handy to try out, I can say
for absolutely, positively certain that using the invokeLater method on
EventQueue (and the SwingUtilities version simply calls the one in
EventQueue) does work on my Mac in 1.4.2.  I've put a slightly modified
version of our app on here that uses this method in numerous places, and
all work as expected.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama

jdilip@gmail.com - 24 Feb 2006 16:50 GMT
Ok, can you tell me how using the other way round you got your code/app
running on MAC instead of using SwingWorker or
SwingUtilities.invokelater();
Steve W. Jackson - 24 Feb 2006 18:30 GMT
> Ok, can you tell me how using the other way round you got your code/app
> running on MAC instead of using SwingWorker or
> SwingUtilities.invokelater();

It's "Mac", not "MAC"...

In order to use SwingUtilities.invokeLater, you should understand the
event handling mechanisms in Swing.  That is, there's basically a single
event dispatching thread on which some important behaviors take place,
like firing action events, updating (painting) components, etc.

If you've got code that's not on the EDT and you want to do something
that should be on it, you pass a Runnable to the above method.  Your
code keeps on going, having passed the Runnable.  The Runnable's run()
method will be invoked when its turn on the EDT's queue comes up.

What platform you do that on isn't relevant.  It's how Java Swing works.  
My code was written on a PC, and the app in question is distributed for
Windows and Linux, but I'm a Mac user by preference.  So I simply
brought the code over to my Mac, made some minor changes needed to
disable some code that required JNI code I don't have on my Mac, and ran
it to see how it works.  The parts that used invokeLater() worked fine.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama

Roedy Green - 24 Feb 2006 20:04 GMT
On Fri, 24 Feb 2006 12:30:02 -0600, "Steve W. Jackson"
<stevewjackson@charter.net> wrote, quoted or indirectly quoted someone
who said :

>It's "Mac", not "MAC"...

A MAC is the unique serial number burned into your Ethernet chip that
makes it possible for Ethernet to hit the ground running without some
scheme to first assign everyone unique addresses.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 25 Feb 2006 10:18 GMT
On Fri, 24 Feb 2006 20:04:03 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
indirectly quoted someone who said :

>>It's "Mac", not "MAC"...
>
>A MAC is the unique serial number burned into your Ethernet chip that
>makes it possible for Ethernet to hit the ground running without some
>scheme to first assign everyone unique addresses.

see http://mindprod.com/jgloss/mac.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

jdilip@gmail.com - 25 Feb 2006 13:06 GMT
Is there any other way where in i can call the execution of the
doFininshed method instead of using
SwingUtilities.invokeLater(doFinished); so that i can test it.
steve - 25 Feb 2006 21:54 GMT
> Is there any other way where in i can call the execution of the
> doFininshed method instead of using
> SwingUtilities.invokeLater(doFinished); so that i can test it.

O.K lets stop messing about,   send us the code that does not work & i will  
run it on my mac.
Thomas Hawtin - 24 Feb 2006 17:01 GMT
>> It sounds like a deadlock of some form. If you get a stack dump it may
>> show up. I don't know the Mac way of doing things. On Windows it would
>> be Ctrl-Break from the console. On Linux Ctrl-\ from the console, or use
>> jstack <process-id>.

> There is no "Mac way" in Java, only Apple's JVM that is fully compliant
> with Sun's JLS.

I don't understand what you are getting at. As far as I am aware
Ctrl-Break, Ctrl-\ and jstack are not in any of the specs. They are
system/JRE-specific. JLS defines the Java language, which the JVM
doesn't need to deal with.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Steve W. Jackson - 24 Feb 2006 18:33 GMT
> >> It sounds like a deadlock of some form. If you get a stack dump it may
> >> show up. I don't know the Mac way of doing things. On Windows it would
[quoted text clipped - 10 lines]
>
> Tom Hawtin

You're right -- your mention of "Mac way" referred to how to break the
app, not to something language related.

FWIW, "jstack" isn't available in my 1.4.2 implementation, though it is
in 1.5 (both Mac and Windows).  But Mac OS X has a BSD-based heart, so
I'm assuming that whatever is useful in Linux or other "Unix-alikes"
would work here.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama

jdilip@gmail.com - 24 Feb 2006 16:41 GMT
I am using the 3rd version of SwingWorker Class

* This is the 3rd version of SwingWorker (also known as
* SwingWorker 3), an abstract class that you subclass to
* perform GUI-related work in a dedicated thread.  For
* instructions on and examples of using this class, see:
*
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
*
* Note that the API changed slightly in the 3rd version:
* You must now invoke start() on the SwingWorker after
* creating it.
hiwa - 24 Feb 2006 18:50 GMT
Basically you don't need to wrap the SwingWorker
finished() method with the invokeLater(). SwingWorker
is already automatically handling the EDT issue for it.
And the finished() method is a callback that you should
not call from your code. So your use of invokeLater()
is an unnecessary redundancy at best, and, might be
harmful at worst.
Chris Uppal - 24 Feb 2006 19:57 GMT
> SwingUtilities.invokeLater(doFinished); line of SwingWorker class
> doesnot execute on mac pc. [...]
> Note here i do not have any Swing GUI in picture.

If your application doesn't use Swing, why are you calling invokeLater() at all
?

   -- chris
jdilip@gmail.com - 25 Feb 2006 12:59 GMT
I have a class which extends SwingWorker Class. And this common class
is used in my Swing app as well as non-swing app. My non-Swing app is
saught of helper class for other app using thru JNI. Thats why i am
using this class
John C. Bollinger - 26 Feb 2006 02:34 GMT
> I have a class which extends SwingWorker Class. And this common class
> is used in my Swing app as well as non-swing app. My non-Swing app is
> saught of helper class for other app using thru JNI. Thats why i am
> using this class

You have a design problem here.  A class that is not restricted to use
in the context of a Swing-based GUI should *not* extend SwingWorker.  It
clearly isn't one -- it's more general than that.

Moreover, I agree with Chris's implication that you shouldn't be using
SwingUtilities.invokeLater() an a non-Swing application.  You should not
be attempting to execute code on the event dispatch thread that doesn't
relate to producing or handling AWT events.  It's plain incorrect.  And
given that it isn't in fact working on Mac (and you want it to do), I'd
say it's high time that you went back and did it right.

I suppose that what you want is an asynchronous job execution mechanism.
 It is a bit tricky to write one yourself, but eminently doable.
Alternatively, you may be able to find a general-purpose utility already
available that suits your purpose.

Signature

John Bollinger
jobollin@indiana.edu

jdilip@gmail.com - 27 Feb 2006 15:43 GMT
Right, i want an asynchronous job execution mechanism. As you mentioned
there may be general-purpose utility already available that suits my
purpose. Are you aware of any such utility that can be handy for me.
jdilip@gmail.com - 27 Feb 2006 15:44 GMT
Right, i want an asynchronous job execution mechanism. As you mentioned
there may be general-purpose utility already available that suits my
purpose. Are you aware of any such utility that can be handy for me.
John C. Bollinger - 28 Feb 2006 01:42 GMT
> Right, i want an asynchronous job execution mechanism. As you mentioned
> there may be general-purpose utility already available that suits my
> purpose. Are you aware of any such utility that can be handy for me.

I didn't realize you had posted this in addition to e-mailing me.  Don't
do that.  If you want a private response, e-mail.  If a public one, or
you don't care, post.

For those interested, I offered the possibilities of using a
java.util.Timer and of using a thread pool, possibly one with only a
single thread.  The latter is the general Java solution to asynchronous
job execution.  The former is a bit of a hack that nevertheless can
emulate SwingUtilities.invokeLater() quite closely.

Signature

John Bollinger
jobollin@indiana.edu

steve - 25 Feb 2006 21:47 GMT
> Hi
> SwingUtilities.invokeLater(doFinished); line of SwingWorker class
[quoted text clipped - 9 lines]
> Thanks
> Dilip Jain

I program extensively on the mac using java , and i can say my  
invokedLater(), is working.

which  , JVM are you using 1.4 or  1.5?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.