Cannot open a Swing JFrame when using OSGi [message #81663] |
Sun, 21 January 2007 09:48 |
Eclipse User |
|
|
|
Originally posted by: alterego.clear.net.nz
Hi all,
I am developing using Eclipse 3.2.1, JDK5.0 on Max OS X 10.4.
I have a plugin project which defines an Application and a Product. I launch the Application using an Eclipse Application launch target from within the IDE (selecting the 'Run an Application' option on the Main tab in the launch configuration).
The dependencies for my plugin project are:
<pre>
org.eclipse.equinox.common_3.2.0.v20060603.jar
org.eclipse.core.runtime_3.2.0.v20060603.jar
org.eclipse.core.contenttype_3.2.0.v20060603.jar
org.eclipse.core.jobs_3.2.0.v20060603.jar
org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601. jar
org.eclipse.equinox.preferences_3.2.1.R32x_v20060717.jar
org.eclipse.equinox.registry_3.2.1.R32x_v20060814.jar
</pre>
So there are no RCP, SWT or JFace dependencies.
The code for my Application looks like this:
<pre>
package my.application;
import javax.swing.JFrame;
import org.eclipse.core.runtime.IPlatformRunnable;
public class Application implements IPlatformRunnable {
public Object run(Object args) throws Exception {
try {
System.out.println("opening frame");
JFrame frame = new JFrame("Test");
frame.setSize(100, 100);
frame.validate();
frame.setVisible(true);
}
catch (Exception e) {
e.printStackTrace();
}
return IPlatformRunnable.EXIT_OK;
}
}
</pre>
When I launch the Application, it exits immediately. Stepping through using the debugger reveals that when frame.setVisible(true) is called, the call returns immediately. No JFrame is ever shown.
If I run this class as a normal Java application, for example by adding the following code and just running it directly:
<pre>
public static void main(String... args) {
try {
new Application().run(args);
}
catch (Exception e) {
e.printStackTrace();
}
}
</pre>
Then it works as expected, the JFrame is opened.
Is there some reason why Swing doesn't work when launched as an Eclipse Application? Is this a problem with OS X? I haven't had the opportunity to try this on Windows yet, so don't know if it works there.
Thanks,
Jesse.
|
|
|
Re: Cannot open a Swing JFrame when using OSGi [message #81682 is a reply to message #81663] |
Sun, 21 January 2007 12:59 |
Eclipse User |
|
|
|
Originally posted by: alex_blewitt.yahoo.com
There have been problems with the SWT_AWT bridge (which supports the JFrame that you're trying to create) on Mac OS X. I believe that it is fixed, but maybe not until the Eclipse 3.3 stream. Have you tried this with Eclipse 3.3M4?
Alex.
|
|
|
Re: Cannot open a Swing JFrame when using OSGi [message #81695 is a reply to message #81663] |
Sun, 21 January 2007 18:10 |
Eclipse User |
|
|
|
Originally posted by: alterego.clear.net.nz
I just tried this with Eclipse 3.3M4. Same result as before, no JFrame is opened. Also, I noticed the following messages are output to std err as a result of instantiating JFrame (this also occurs with Eclipse 3.2.1):
<pre>
2007-01-21 18:05:51.323 java[1969] [Java CocoaComponent compatibility mode]: Enabled
2007-01-21 18:05:51.323 java[1969] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
</pre>
Regardless, I would have thought that the SWT_AWT bridge would not be needed, since my code has no dependency on SWT or JFace at all, just the Eclipse OSGi and core runtime stuff. So why would this prevent me using Swing?
Thanks and regards,
Jesse.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04711 seconds