package com.test;
import java.awt.BorderLayout;
import java.awt.Canvas;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Sword extends JFrame {
private static final long serialVersionUID = -7511601547609623217L;
private static OleFrame oleFrame1;
public static void main(String[] args) {
final JFrame frame = new JFrame();
//关键 使用 canvas 进行交互
Canvas canvas = new Canvas();
JPanel jp = new JPanel();
// jp.setBounds(0, 0, 3, 340);
frame.getContentPane().add(jp);
jp.add(canvas,BorderLayout.CENTER);
jp.getParent().add(canvas,BorderLayout.CENTER);
// frame.getContentPane().add(canvas,BorderLayout.CENTER);
frame.setVisible(true);
frame.setSize(600, 600);
final Display display = new Display();
//利用SWT_AWT.new_Shell 交互
final Shell shell = SWT_AWT.new_Shell(display,canvas);
shell.setLayout(new FillLayout());
shell.layout();
shell.setSize(800, 600);
initGUI(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
private static void initGUI(Shell shell) {
try {
// FillLayout thisLayout = new FillLayout(org.eclipse.swt.SWT.HORIZONTAL);
// shell.setLayout(thisLayout);
// shell.setSize(229, 54);
oleFrame1 = new OleFrame(shell, SWT.NONE);
try {
OleClientSite site = new org.eclipse.swt.ole.win32.OleClientSite(
oleFrame1, org.eclipse.swt.SWT.NONE,
// "Excel.Sheet");
"Word.Document");
// site.setBounds(0, 0, 104, 54);
// site.setBounds(0, 0, 1800, 800);
site.doVerb(org.eclipse.swt.ole.win32.OLE.OLEIVERB_SHOW);
} catch (org.eclipse.swt.SWTException e) {
String str = "Create OleClientSite Error"
+ e.toString();
System.out.println(str);
return;
}
shell.layout();
} catch (Exception e) {
e.printStackTrace();
}
}
public Sword() {
super();
}
}

xiaofengtoo
- 粉丝: 9
最新资源
- 【IOS应用源码】ZeroIB.zip
- 【IOS应用源码】ZKRevealingTableCellView for iOS-1.zip
- 【IOS应用源码】ZKRevealingTableCellView for iOS.zip
- 【IOS应用源码】Zoo.zip
- 【IOS应用源码】贝塞尔曲线demo:一个运动的物体:PathMove for iOS.zip
- 【IOS应用源码】贝塞尔曲线demo:一个运动的物体:PathMove for iOS-1.zip
- 【IOS应用源码】巴黎自行车信息查询软件源码VeloParis100416_1_Distribution_1.1.zip
- 【IOS应用源码】彩色渐变LBGradient for iOS.zip
- 【IOS应用源码】本地化与国际化.zip
- 【IOS应用源码】窗口淡入淡出加视图旋转SwitchView.zip
- 【IOS应用源码】从GIF动画创建一个动态UIImages 对象.zip
- 【IOS应用源码】从上往下拉出现加载view,动态加载内容.zip
- 【IOS应用源码】从头教你不用IB写漂亮的程序 niblesshelloworld.zip
- 【IOS应用源码】从上往下拉动态加载.zip
- 【IOS应用源码】从上往下拉动态加载3.zip
- 【IOS应用源码】从下往下拉进行列表内容动态加载.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



- 1
- 2
- 3
- 4
- 5
- 6
前往页