[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [platform-swt-dev] SWT and Swing ...
|
Yes,
Here is some very basic example code that works. I have more advanced but
it includes a lot of third party packages at the moment.
Enjoy,
Chris
/*
* Created on Jun 5, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package swtdemo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* @author nortonck
*
*/
public class SwingDemo {
/**
*
*/
public SwingDemo() {
super();
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
/* Create AWT Frame */
final java.awt.Frame frame = new java.awt.Frame("Outer
window is java.awt.Frame");
frame.setSize(350, 300);
frame.setVisible(true);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent
e) {
e.getWindow().dispose();
}
public void windowClosed(java.awt.event.WindowEvent
e) {
System.exit(0);
}
});
java.awt.Panel panel = new java.awt.Panel();
frame.add(panel);
final java.awt.Canvas canvas = new java.awt.Canvas();
panel.add(canvas);
final Display display = new Display();
final Shell shell =
org.eclipse.swt.internal.awt.win32.SWT_AWT.new_Shell(display, canvas);
shell.setLayout(new FillLayout());
org.eclipse.swt.ole.win32.OleFrame oleFrame = new
org.eclipse.swt.ole.win32.OleFrame(shell, SWT.NONE);
org.eclipse.swt.ole.win32.OleControlSite
controlSite;
try {
controlSite = new
org.eclipse.swt.ole.win32.OleControlSite(oleFrame, SWT.NONE,
"Shell.Explorer");
} catch (SWTException ex) {
System.out.println("Failed to create
ActiveX control: " +ex.getMessage());
return;
}
canvas.setSize(350, 300);
controlSite.doVerb(org.eclipse.swt.ole.win32.OLE.OLEIVERB_INPLACEACTIVATE);
org.eclipse.swt.ole.win32.OleAutomation automation =
new org.eclipse.swt.ole.win32.OleAutomation(controlSite);
// int[] rgdispid = automation.getIDsOfNames(new
String[]{"GoHome"});
// int dispIdMember = rgdispid[0];
// automation.invoke(dispIdMember);
Variant[] rgvarg = new Variant[1]; // this is the
URL parameter
rgvarg[0] = new
Variant("http://click.nielsenmedia.com/");
Variant pVarResult = automation.invoke(500, rgvarg);
// Need to invoke the AWT layout manager or AWT and Swing
widgets willnot
// be visible
shell.open();
frame.validate();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
-----Original Message-----
From: Christian Sauer [mailto:christian.sauer@xxxxxxxxxxxxx]
Sent: Friday, June 27, 2003 3:42 AM
To: platform-swt-dev@xxxxxxxxxxx
Subject: [platform-swt-dev] SWT and Swing ...
Hello,
is it generally possible to use a SWT based UI component
(e.g. browser panel) within a Swing frame?
thanks for an advice.
cheers,
chris
-------------------------------------------------------------------------
Giniality AG - Christian Sauer; Steinenberg 21, CH-4051 Basel
Phone: +41 61 226 99 66; Fax: +41 61 226 99 69;
E-Mail: christian.sauer@xxxxxxxxxxxx; WWW: http://www.giniality.com
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev