Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » swt_awt bridge
swt_awt bridge [message #467486] Wed, 01 February 2006 00:14 Go to next message
Eclipse UserFriend
Originally posted by: wusman.visionbytes.com

Hi guys,
I'm trying to embed an swt app in an awt app and am getting the following
error:
Exception in thread "main" java.lang.IllegalArgumentException: Argument not
valid [peer not created]

at org.eclipse.swt.SWT.error(SWT.java:2926)

at org.eclipse.swt.awt.SWT_AWT.new_Shell(SWT_AWT.java:259)

at TestAppBeta.main(TestAppBeta.java:34)


The code (available on the net at
http://www.eclipsezone.com/eclipse/forums/m91977887.html) is:
public static void main(String[] args)
{
Frame frame = new Frame("My AWT Frame"); // java.awt.Frame
frame.setLayout( new BorderLayout() );
Canvas canvas = new Canvas(); // java.awt.Canvas
frame.add(canvas, BorderLayout.CENTER);

Display display = new Display(); // display object to manage SWT
lifecycle.
Shell swtShell = SWT_AWT.new_Shell(display, canvas);
Button m_button = new Button(swtShell, SWT.PUSH);
m_button.setText( "button" );

// invoke the AWT frame rendering by making the frame visible
// This starts the EDT
frame.setVisible(true);

// standard SWT dispatch loop
while(!swtShell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}
swtShell.dispose();
}

The error is received on the line:
"Shell swtShell = SWT_AWT.new_Shell(display, canvas);"

Has anybody had any luck embedding an swt shell in an AWT Frame?
The same function when used for an applet
( http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/e
clipse/swt/snippets/Snippet157.java?rev=HEAD)
works fine. Any ideas why this may be so?

Hope somebody can help or can get this piece of code working. I'm using 1.5
java jdk and downloaded swt from the swt home on eclipse.org.

Thanks
waleed
Re: swt_awt bridge [message #467492 is a reply to message #467486] Wed, 01 February 2006 01:57 Go to previous message
Eclipse UserFriend
Originally posted by: wusman.visionbytes.com

Hi guys,

Found out what the trouble was, its logged in eclipse's bug log as
https://bugs.eclipse.org/bugs/show_bug.cgi?id=69381
although it was very hard to find...it took me 1 and a half days of googling
guess its cause the error is logged under different circumstances.

Apparently you have to set the parent of the canvas to be visible (i.e.
frame.setvisible(true))



"waleed usman" <wusman@visionbytes.com> wrote in message
news:droup3$ir5$1@utils.eclipse.org...
> Hi guys,
> I'm trying to embed an swt app in an awt app and am getting the following
> error:
> Exception in thread "main" java.lang.IllegalArgumentException: Argument
not
> valid [peer not created]
>
> at org.eclipse.swt.SWT.error(SWT.java:2926)
>
> at org.eclipse.swt.awt.SWT_AWT.new_Shell(SWT_AWT.java:259)
>
> at TestAppBeta.main(TestAppBeta.java:34)
>
>
> The code (available on the net at
> http://www.eclipsezone.com/eclipse/forums/m91977887.html) is:
> public static void main(String[] args)
> {
> Frame frame = new Frame("My AWT Frame"); // java.awt.Frame
> frame.setLayout( new BorderLayout() );
> Canvas canvas = new Canvas(); // java.awt.Canvas
> frame.add(canvas, BorderLayout.CENTER);
>
> Display display = new Display(); // display object to manage SWT
> lifecycle.
> Shell swtShell = SWT_AWT.new_Shell(display, canvas);
> Button m_button = new Button(swtShell, SWT.PUSH);
> m_button.setText( "button" );
>
> // invoke the AWT frame rendering by making the frame visible
> // This starts the EDT
> frame.setVisible(true);
>
> // standard SWT dispatch loop
> while(!swtShell.isDisposed())
> {
> if(!display.readAndDispatch())
> display.sleep();
> }
> swtShell.dispose();
> }
>
> The error is received on the line:
> "Shell swtShell = SWT_AWT.new_Shell(display, canvas);"
>
> Has anybody had any luck embedding an swt shell in an AWT Frame?
> The same function when used for an applet
>
( http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/e
> clipse/swt/snippets/Snippet157.java?rev=HEAD)
> works fine. Any ideas why this may be so?
>
> Hope somebody can help or can get this piece of code working. I'm using
1.5
> java jdk and downloaded swt from the swt home on eclipse.org.
>
> Thanks
> waleed
>
>
Previous Topic:GC.drawImage to shrink does not look good on Windows
Next Topic:Need a Workaround to get a Working ScrollBar
Goto Forum:
  


Current Time: Fri Aug 23 21:59:19 GMT 2019

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

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

Back to the top