[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: Problem using Swing from org.eclipse.core.runtime.applications extension

Thank you for the suggestion. I have tried using both invokeLater and
invokeAndWait to construct and show my JFrame and it makes no difference.
The call to setVisible still returns immediately.

The only explanation I can think of for this is that my program might have
already created and shown another Swing component. But I believe that the
only other code that should have run by the time my IPlatformRunnable is
called is from the Eclipse runtime, which presumably does nothing with
Swing. So I'm afraid I still don't see what's wrong.

Jean-Michel Lemieux wrote:

> Are you sure that the application is being called from the UI thread? 
> Try adding the following:

> javax.swing.SwingUtilities.invokeLater(new Runnable() {
>      public void run() {
>          frame.setVisible(true);
>      }
> });


> Harold Mills wrote:

> > I have an existing Swing application to which I would like to add plug-in
> > support. I hope to use the Eclipse plug-in facility for this purpose. To
> > convince myself that this can work, I'm trying to write a small Eclipse
> > plug-in containing an org.eclipse.core.runtime.applications extension as
> > follows:
> > 
> > package clo.brp.rcp;
> > 
> > import javax.swing.JFrame;
> > 
> > import org.eclipse.core.runtime.IPlatformRunnable;
> > 
> > public class RcpApplication implements IPlatformRunnable {
> > 
> >     public Object run(Object args) {
> > 
> >     	JFrame frame = new JFrame("RcpApplication");
> >     	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> >     	frame.setVisible(true);
> > 
> >     	System.out.println("back from setVisible");
> > 
> >     	return IPlatformRunnable.EXIT_OK;
> > 
> >     }
> >     
> > }
> > 
> > This almost works, except that the call to frame.setVisible returns
> > immediately instead of blocking until the user dismisses the JFrame, the
> > normal behavior for a Swing application. So the JFrame appears only
> > briefly and then the program exits. Does anybody know how I can fix this?
> > 
> >