pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Dorsey <Jason.Dor...@netiq.com>
Subject RE: Error in launching Pivot in a thread
Date Mon, 23 Apr 2012 13:34:07 GMT
Have your GUI started normally within your MVC app (not within a separate runnable).

When your other threads need to update the GUI use something like this...

public void setStatus(final TestStatus status)
      {

            this.status = status;
            if (label != null)
                  // This was needed as Java requires all UI updates to be made in
                  // the main thread
                  // Otherwise weird things will happen such as updates happening out
                  // of sync or not at all
                  // Also had to declare the status parameter as final to be
                  // accessible to the runnable
                  ApplicationContext.queueCallback(new Runnable()
                  {
                        public void run()
                        {
                              // CHANGE THIS HERE TO WHAT YOU NEED TO HAVE RUN
                              label.setText(status.toString());
                              setStatusInfo();
                        }
                  });
      }

This should get you working...

Jason Dorsey | Engineering Intern
1233 West Loop South
Houston, TX 77027 USA
Jason.Dorsey@netiq.com<mailto:Jason.Dorsey@attachmate.com>
www.attachmate.com<http://www.attachmate.com/>  |  www.netiq.com<http://www.netiq.com/>

From: Ashish Dalela [mailto:ashish.dalela@gmail.com]
Sent: Saturday, April 21, 2012 3:04 PM
To: user@pivot.apache.org
Subject: Re: Error in launching Pivot in a thread

Thanks for your responses. With your suggestion, I have partial success. Here is what I did.

Created a Runnable class View that starts a thread. In the run () function for this class,
I call the queueCallback () to invoke a StartGUI Runnable instance. This starts the Pivot
application alright.

However, when I do a thread.join for the View (and other threads) in main thread the GUI is
never rendered. Any suggestions on what maybe wrong?

Ashish

On Sat, Apr 21, 2012 at 10:54 PM, Noel Grandin <noelgrandin@gmail.com<mailto:noelgrandin@gmail.com>>
wrote:
You should be using ApplicationContext#queueCallback() to push code
onto the event thread, so that your other threads do not need
to call pivot stuff directly.

On Sat, Apr 21, 2012 at 18:24, Ashish Dalela <ashish.dalela@gmail.com<mailto:ashish.dalela@gmail.com>>
wrote:
>
> The issue is that if I have multiple threads then I have to also be doing
> thread.join for the other threads, which in effect suspends the main thread
> until the other threads exit and makes the window unresponsive.
>
> I thought this is what PIVOT-780 is about, but I might be wrong.
>
> Ashish
>
>
> On Sat, Apr 21, 2012 at 8:53 PM, Noel Grandin <noelgrandin@gmail.com<mailto:noelgrandin@gmail.com>>
wrote:
>>
>> You can only call window.open from the event thread, not from other
>> threads.
>>
>>
>> On Sat, Apr 21, 2012 at 14:00, Ashish Dalela <ashish.dalela@gmail.com<mailto:ashish.dalela@gmail.com>>
>> wrote:
>> > Hi,
>> >
>> > I'm a new user, and hope I can find some help here.
>> >
>> > I have a MVC application, with each M/V/C run in separate threads. The
>> > Pivot
>> > code runs in the View thread, and I see the following error at startup:
>> >
>> > Exception in thread "Thread-6" java.lang.IllegalStateException: this
>> > method
>> > can only be called from the AWT event dispatch thread, and not from
>> > "Thread-6"
>> >
>> > The error is seen while executing the following code:
>> >
>> > <snip>
>> > this.window = (Window)
>> > bxmlSerializer.readObject(getClass().getResource("abc.bxml"));
>> > window.open(this.display);
>> > </snip>
>> >
>> > A similar issue seems to have been reported and (apparently) fixed
>> > earlier: https://issues.apache.org/jira/browse/PIVOT-780
>> >
>> > I'm wondering if this is regressed, or what is the right version to get
>> > this
>> > fix? I'm using 2.0.1.
>> >
>> > Thanks for any help,
>> >
>> > Regards,
>> > Ashish
>
>


Mime
View raw message