Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Swing vs SWT issues
Swing vs SWT issues [message #462753] Tue, 18 October 2005 23:41 Go to next message
Peter is currently offline Peter
Messages: 51
Registered: July 2009
Member
Hi All,

I basically have two questions regaring SWT and SWING integration
if I can get the answers for the following that will be great.

1)

I allready have a application(which extends JFrame as follows

public class ExistingAPP extends JFrame implements WindowListener

and then when I try to use the java.awt.Frame xxx=
SWT_AWT.new_Frame(xxxxx);

it gives the following error

Exception in thread "main" java.lang.IllegalArgumentException: adding a
window to a container

The code sample I used is

final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("SWT Swing Example");
Composite locationComp = new Composite(shell, SWT.EMBEDDED);
final Composite comp = new Composite(shell, SWT.NONE);

Composite tableComp = new Composite(comp, SWT.EMBEDDED);

java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(tableComp);

java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());

fileTableFrame.add(panel);
LogSvr.logDebug("Going to construct JFram Appliction");
panel.add(new JFrameApplication());

shell.open();
while(!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();


2) The second question is
In a primitive SWT application the above stated JFrameApplication
starts though it gives the above error, but in a wizard based SWT
application it gives the following error and doesnt not start the
application

Unhandled event loop exception
Reason:
com/xxxx/xxxx/......

What is meant by this.



Waiting for a early reply

Thanks,
Peter
Re: Swing vs SWT issues [message #462755 is a reply to message #462753] Tue, 18 October 2005 23:43 Go to previous messageGo to next message
Peter is currently offline Peter
Messages: 51
Registered: July 2009
Member
Regarding the question 1, I like to have a answer without changing the
existing JFrame application.

thanks
Peter
Re: Swing vs SWT issues [message #462757 is a reply to message #462755] Wed, 19 October 2005 00:03 Go to previous messageGo to next message
Peter is currently offline Peter
Messages: 51
Registered: July 2009
Member
Hi All,

I did further investigation and noticed the following in the .log file.

java.lang.NoClassDefFoundError: com/xxxxx/xx/xx

The Parent Application is a plugin, but the com/xxxxx/xx/xx application is
not a plugin but a different JFrame application.

All the jar files are in the classpath and the application compiles with
no problem, can someone let me know how to handle this.

thanks
Peter
Re: Swing vs SWT issues [message #462759 is a reply to message #462753] Wed, 19 October 2005 02:30 Go to previous messageGo to next message
Haris Peco is currently offline Haris Peco
Messages: 1072
Registered: July 2009
Senior Member
Peter,
for 1) - you can't add frame (JFrame) to frame - it is swing constraint
you can try extract panel from your application and add panel in SWT_AWT
frame
for 2) it depends from 1 probably
Peco

Peter wrote:

> Hi All,
>
> I basically have two questions regaring SWT and SWING integration
> if I can get the answers for the following that will be great.
>
> 1)
>
> I allready have a application(which extends JFrame as follows
>
> public class ExistingAPP extends JFrame implements WindowListener
>
> and then when I try to use the java.awt.Frame xxx=
> SWT_AWT.new_Frame(xxxxx);
>
> it gives the following error
>
> Exception in thread "main" java.lang.IllegalArgumentException: adding a
> window to a container
>
> The code sample I used is
>
> final Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setText("SWT Swing Example");
> Composite locationComp = new Composite(shell, SWT.EMBEDDED);
> final Composite comp = new Composite(shell, SWT.NONE);
>
> Composite tableComp = new Composite(comp, SWT.EMBEDDED);
>
> java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(tableComp);
>
> java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());
>
> fileTableFrame.add(panel);
> LogSvr.logDebug("Going to construct JFram Appliction");
> panel.add(new JFrameApplication());
>
> shell.open();
> while(!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> display.dispose();
>
>
> 2) The second question is
> In a primitive SWT application the above stated JFrameApplication
> starts though it gives the above error, but in a wizard based SWT
> application it gives the following error and doesnt not start the
> application
>
> Unhandled event loop exception
> Reason:
> com/xxxx/xxxx/......
>
> What is meant by this.
>
>
>
> Waiting for a early reply
>
> Thanks,
> Peter
Re: Swing vs SWT issues [message #462771 is a reply to message #462759] Wed, 19 October 2005 02:31 Go to previous messageGo to next message
Peter is currently offline Peter
Messages: 51
Registered: July 2009
Member
I really do not like to change the existing JFrame application. Reason is
it uses lot of properties and features of the JFrame,

Isnt there any other workaround
Re: Swing vs SWT issues [message #462776 is a reply to message #462771] Wed, 19 October 2005 05:20 Go to previous messageGo to next message
Haris Peco is currently offline Haris Peco
Messages: 1072
Registered: July 2009
Senior Member
Peter wrote:

> I really do not like to change the existing JFrame application. Reason is
> it uses lot of properties and features of the JFrame,
>
> Isnt there any other workaround
no, you can open your application in another window only
Re: Swing vs SWT issues [message #462777 is a reply to message #462776] Wed, 19 October 2005 04:46 Go to previous messageGo to next message
Peter is currently offline Peter
Messages: 51
Registered: July 2009
Member
Not even that,

it gives the following error message in the console

Unhandled event loop exception
Reason:
com/xx/xxxx/xxxxx

Also in the .log file it gives the following error
java.lang.NoClassDefFoundError: com/xx/xxxx/xxxxx

The parent application is a plugin, but the application which gonna popup
is a seperate standolone application.

The compilation and everything is successful

Thanks
Re: Swing vs SWT issues [message #462789 is a reply to message #462777] Wed, 19 October 2005 13:42 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Peter wrote:
> Not even that,
>
> it gives the following error message in the console
>
> Unhandled event loop exception
> Reason:
> com/xx/xxxx/xxxxx
>
> Also in the .log file it gives the following error
> java.lang.NoClassDefFoundError: com/xx/xxxx/xxxxx
>
> The parent application is a plugin, but the application which gonna
> popup is a seperate standolone application.
>
> The compilation and everything is successful
>
> Thanks
>
>

Compilation is controlled by the project build path properties. Runtime
is controlled by the manifest (jars have to belong to a plugin). How
have you included your stand alone jars in a plugin, so they can be used
by a plugin?

There are a number of steps for using 3rd party (an external) jars with
plugins ... the easiest is of course creating a New plugin from existin
jar archives. The other steps are available in a couple of other
threads on the news group.

Later,
PW


Re: Swing vs SWT issues [message #462799 is a reply to message #462777] Wed, 19 October 2005 17:15 Go to previous messageGo to next message
Haris Peco is currently offline Haris Peco
Messages: 1072
Registered: July 2009
Senior Member
Peter wrote:

> Not even that,
>
> it gives the following error message in the console
>
> Unhandled event loop exception
> Reason:
> com/xx/xxxx/xxxxx
>
> Also in the .log file it gives the following error
> java.lang.NoClassDefFoundError: com/xx/xxxx/xxxxx
>
> The parent application is a plugin, but the application which gonna popup
> is a seperate standolone application.
>
> The compilation and everything is successful
>
> Thanks
you don't need SWT_AWT for separate window - call your application
with 'new MyApplication()' or similar without SWT_AWT frame
it will open new window
if you have NoClassDEfDoundError add libraries in plugin runtime
Re: Swing vs SWT issues [message #462835 is a reply to message #462789] Thu, 20 October 2005 01:45 Go to previous messageGo to next message
Peter is currently offline Peter
Messages: 51
Registered: July 2009
Member
Isnt it enough to add the jars as follows in the plugin.xml

<runtime>
<library name="first.jar">
<export name="*"/>
</library>
<library name="second.jar">
<export name="*"/>
</library>
</runtime>

Still it gives the following error

Unhandled event loop exception
Reason:
com/XXXXX/XX/XXXX

What is the physical location that the jar files needs to reside.
Currently I put inside the plugin

eclipse\plugins\com.my.newplugin\


Thanks,
Lalitha
Re: Swing vs SWT issues [message #462836 is a reply to message #462835] Thu, 20 October 2005 04:11 Go to previous messageGo to next message
Haris Peco is currently offline Haris Peco
Messages: 1072
Registered: July 2009
Senior Member
Peter wrote:

> Isnt it enough to add the jars as follows in the plugin.xml
>
> <runtime>
> <library name="first.jar">
> <export name="*"/>
> </library>
> <library name="second.jar">
> <export name="*"/>
> </library>
> </runtime>
>
> Still it gives the following error
>
> Unhandled event loop exception
> Reason:
> com/XXXXX/XX/XXXX
>
> What is the physical location that the jar files needs to reside.
> Currently I put inside the plugin
>
> eclipse\plugins\com.my.newplugin\
you set jars correct.
Can you try in runtime workbench ?
Re: Swing vs SWT issues [message #462909 is a reply to message #462836] Thu, 20 October 2005 23:17 Go to previous messageGo to next message
Peter is currently offline Peter
Messages: 51
Registered: July 2009
Member
I am running like that,

What is the defaul location to put the thirdparty jars
Re: Swing vs SWT issues [message #462910 is a reply to message #462909] Fri, 21 October 2005 01:30 Go to previous message
Haris Peco is currently offline Haris Peco
Messages: 1072
Registered: July 2009
Senior Member
Peter wrote:

> I am running like that,
>
> What is the defaul location to put the thirdparty jars

i make separate plugin and lib subdirectory, but it isn't important
you have to add it in runtime and export packages what you want use in
another plugin (i export all ,but it have to export every packages in new
MANIFEST.MF; before it exists *)

you export it on old way (old plugin.xml) and you check is it in runtime tab
is it fine when you use this packages in another plugins (don't add packages
in build path properties - add only dependency for jars plugins - then you
can environment like runtime)

Peco
Previous Topic:Fields on a FlowLayout can't be updated
Next Topic:Convert LayoutManagers to SWT ...
Goto Forum:
  


Current Time: Sun Sep 21 04:12:41 GMT 2014

Powered by FUDForum. Page generated in 0.01923 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software