- 浏览: 68868 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
Alex_Cheung:
对了,第二个没有提取码,请知悉。
一大波视频分享 -
Alex_Cheung:
谢谢分享。
一大波视频分享 -
Jiy:
很详细,谢谢分享
java并发之同步辅助类Phaser -
walle1027:
非常不错,学习了。
java并发之同步辅助类Phaser -
huangjinjin520:
somefuture 写道除了单词写错了 其他挺好的已更正
dubbo注解使用详解
这里用的是SWT/JFace开发application中SWT自带的org.eclipse.swt.ole.win32 包可以支持内嵌OLE和ActiveX。
具体用法如下:
//创建一个OleFrame做为OLE(或ActiveX)的框架
OleFrame oleFrame = new OleFrame(this, SWT.NONE);
//创建ActiveX的容器,其中的classID是ActiveX的classid,在注册表中可以找到
OleControlSite oleControl = new OleControlSite(oleFrame, SWT.NONE, “classID”);
//OleAutomation类用来执行ActiveX中的方法
OleAutomation oleAutomation = new OleAutomation(oleControl);
//将ActiveX显示在application中
oleControl.doVerb(OLE.OLEIVERB_SHOW);
调用AcitveX中方法的具体过程:
1、不带参数的方法调用
//获取Method Name的ID,Method Name为ActiveX中具体的方法名
int[] regspid = oleAutomation.getIDsOfNames(new String[] { "MethodName" });
int dispIdMember = regspid[0];
//方法调用
oleAutomation.invoke(dispIdMember);
2、带参数的方法调用
//获取Method Name的ID,Method Name为ActiveX中具体的方法名
int[] regspid = oleAutomation.getIDsOfNames(new String[] { "MethodName" });
int dispIdMember = regspid[0];
//设置方法的具体参数。Variant数组的长度为MethodName方法参数的个数
//假设有四个参数
Variant[] rgvarg = new Variant[4];
rgvarg[0] = new Variant(fileID);
rgvarg[1] = new Variant(itdsURL);
rgvarg[2] = new Variant(idType);
rgvarg[3] = new Variant(reportURL);
//方法调用
oleAutomation.invoke(dispIdMember, rgvarg);
调用OLE Exemple:Java程序内嵌Word应用程序
package test.swt;
import java.io.File;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Composite;
public class ActiveXTest
{
private Shell sShell = null;
private Button button = null;
private OleClientSite clientSite;
public static void main(String[] args)
{
Display display =Display.getDefault();
ActiveXTest thisClass = new ActiveXTest();
thisClass.createSShell();
thisClass.sShell.open();
while (!thisClass.sShell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
/**
* This method initializes sShell
*/
private void createSShell()
{
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
sShell = new Shell();
sShell.setText("Shell");
sShell.setLayout(gridLayout);
sShell.setSize(new Point(800, 600));
OleFrame frame = new OleFrame(sShell, SWT.NONE);
button = new Button(sShell, SWT.NONE);
button.setLayoutData(gridData);
button.setText("Save");
button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
{
clientSite.save(new File("d:/test.docx"),true);
}
});
frame.setSize(800,600);
clientSite = new OleClientSite(frame, SWT.NONE,"Word.Document.8");
clientSite.setSize(400,400);
clientSite.doVerb(OLE.OLEIVERB_SHOW);
}
}
SWT调用ActiveX简单总结
public class SWT_ActivexUtil {
private OleFrame _frame;
private OleControlSite _site;
private OleAutomation _auto;
SWT_ActivexUtil(String activexId, OleControlSite site){
if(site == null){
Shell shell = new Shell();
_frame = new OleFrame(shell, SWT.NONE);
_site = new OleControlSite(_frame, SWT.NONE, activexId);
_auto = new OleAutomation(_site);
}else{
_site = site;
_auto = new OleAutomation(site);;
}
}
public int getID(String name){
try {
int[] ids = _auto.getIDsOfNames(new String[]{name});
if(ids.length>=0)
return ids[0];
} catch (RuntimeException e) {
e.printStackTrace();
}
return -1;
}
public Variant[] createVariants(String[] paras){
Variant[] vr = new Variant[paras.length];
for(int i=0;i<paras.length;i++){
vr[i] = new Variant(paras[i]);
}
return vr;
}
public Variant getProperty(String prop){
int propId = getID(prop);
Variant v = null;
try {
v = _auto.getProperty(propId);
} catch (Exception e) {
e.printStackTrace();
}
return v;
}
public void setProperty(String name, String... params){
int propId = getID(name);
if(propId < 0)
return;
if(params.length==1)
_auto.setProperty(propId, new Variant(params[0]));
else{
Variant[] vs = new Variant[params.length];
int i=0;
for(String param:params){
vs[i] = new Variant(param);
i++;
}
_auto.setProperty(propId, vs);
}
}
public void setProperty(String name, Variant... params){
int propId = getID(name);
if(propId < 0)
return;
_auto.setProperty(propId, params);
}
public Variant execute(String methodName, Variant... params){
int mid = getID(methodName);
if(mid<0)
return null;
Variant rtnv;
if(params == null)
rtnv = _auto.invoke(mid);
else
rtnv = _auto.invoke(mid, params);
return rtnv;
}
public Variant execute(String methodName){
int mid = getID(methodName);
if(mid<0)
return null;
Variant rtnv = _auto.invoke(mid);
return rtnv;
}
public void addEventListener(int eventID, OleListener listener){
_site.addEventListener(eventID, listener);
}
public void removeEventListener(int eventID, OleListener listener){
_site.removeEventListener(eventID, listener);
}
}
具体用法如下:
//创建一个OleFrame做为OLE(或ActiveX)的框架
OleFrame oleFrame = new OleFrame(this, SWT.NONE);
//创建ActiveX的容器,其中的classID是ActiveX的classid,在注册表中可以找到
OleControlSite oleControl = new OleControlSite(oleFrame, SWT.NONE, “classID”);
//OleAutomation类用来执行ActiveX中的方法
OleAutomation oleAutomation = new OleAutomation(oleControl);
//将ActiveX显示在application中
oleControl.doVerb(OLE.OLEIVERB_SHOW);
调用AcitveX中方法的具体过程:
1、不带参数的方法调用
//获取Method Name的ID,Method Name为ActiveX中具体的方法名
int[] regspid = oleAutomation.getIDsOfNames(new String[] { "MethodName" });
int dispIdMember = regspid[0];
//方法调用
oleAutomation.invoke(dispIdMember);
2、带参数的方法调用
//获取Method Name的ID,Method Name为ActiveX中具体的方法名
int[] regspid = oleAutomation.getIDsOfNames(new String[] { "MethodName" });
int dispIdMember = regspid[0];
//设置方法的具体参数。Variant数组的长度为MethodName方法参数的个数
//假设有四个参数
Variant[] rgvarg = new Variant[4];
rgvarg[0] = new Variant(fileID);
rgvarg[1] = new Variant(itdsURL);
rgvarg[2] = new Variant(idType);
rgvarg[3] = new Variant(reportURL);
//方法调用
oleAutomation.invoke(dispIdMember, rgvarg);
调用OLE Exemple:Java程序内嵌Word应用程序
package test.swt;
import java.io.File;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Composite;
public class ActiveXTest
{
private Shell sShell = null;
private Button button = null;
private OleClientSite clientSite;
public static void main(String[] args)
{
Display display =Display.getDefault();
ActiveXTest thisClass = new ActiveXTest();
thisClass.createSShell();
thisClass.sShell.open();
while (!thisClass.sShell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
/**
* This method initializes sShell
*/
private void createSShell()
{
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
sShell = new Shell();
sShell.setText("Shell");
sShell.setLayout(gridLayout);
sShell.setSize(new Point(800, 600));
OleFrame frame = new OleFrame(sShell, SWT.NONE);
button = new Button(sShell, SWT.NONE);
button.setLayoutData(gridData);
button.setText("Save");
button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
{
clientSite.save(new File("d:/test.docx"),true);
}
});
frame.setSize(800,600);
clientSite = new OleClientSite(frame, SWT.NONE,"Word.Document.8");
clientSite.setSize(400,400);
clientSite.doVerb(OLE.OLEIVERB_SHOW);
}
}
SWT调用ActiveX简单总结
public class SWT_ActivexUtil {
private OleFrame _frame;
private OleControlSite _site;
private OleAutomation _auto;
SWT_ActivexUtil(String activexId, OleControlSite site){
if(site == null){
Shell shell = new Shell();
_frame = new OleFrame(shell, SWT.NONE);
_site = new OleControlSite(_frame, SWT.NONE, activexId);
_auto = new OleAutomation(_site);
}else{
_site = site;
_auto = new OleAutomation(site);;
}
}
public int getID(String name){
try {
int[] ids = _auto.getIDsOfNames(new String[]{name});
if(ids.length>=0)
return ids[0];
} catch (RuntimeException e) {
e.printStackTrace();
}
return -1;
}
public Variant[] createVariants(String[] paras){
Variant[] vr = new Variant[paras.length];
for(int i=0;i<paras.length;i++){
vr[i] = new Variant(paras[i]);
}
return vr;
}
public Variant getProperty(String prop){
int propId = getID(prop);
Variant v = null;
try {
v = _auto.getProperty(propId);
} catch (Exception e) {
e.printStackTrace();
}
return v;
}
public void setProperty(String name, String... params){
int propId = getID(name);
if(propId < 0)
return;
if(params.length==1)
_auto.setProperty(propId, new Variant(params[0]));
else{
Variant[] vs = new Variant[params.length];
int i=0;
for(String param:params){
vs[i] = new Variant(param);
i++;
}
_auto.setProperty(propId, vs);
}
}
public void setProperty(String name, Variant... params){
int propId = getID(name);
if(propId < 0)
return;
_auto.setProperty(propId, params);
}
public Variant execute(String methodName, Variant... params){
int mid = getID(methodName);
if(mid<0)
return null;
Variant rtnv;
if(params == null)
rtnv = _auto.invoke(mid);
else
rtnv = _auto.invoke(mid, params);
return rtnv;
}
public Variant execute(String methodName){
int mid = getID(methodName);
if(mid<0)
return null;
Variant rtnv = _auto.invoke(mid);
return rtnv;
}
public void addEventListener(int eventID, OleListener listener){
_site.addEventListener(eventID, listener);
}
public void removeEventListener(int eventID, OleListener listener){
_site.removeEventListener(eventID, listener);
}
}
发表评论
-
一大波视频分享
2018-06-09 09:36 10931.ps 链接: https://pan.baidu ... -
利用Sharding-Jdbc实现分表
2018-05-24 22:32 3711你们团队使用SpringMVC+Spr ... -
MINA原理详解
2018-05-19 13:51 14561. 通过SocketConnector同服务器端建立连接 ... -
最近有人说我欺骗消费者,今天来一波视频分享
2018-05-12 21:00 1149最近有人说我欺骗消费者,今天来一波视频分享 dubbo入门 ... -
SVN多版本库环境的搭建
2018-05-02 21:00 1105一、 1、启动SVN sudo svn ... -
前端 Java Python等资源合集大放送
2018-04-21 22:11 662如果需要学习视频,欢 ... -
Nginx会话保持之nginx-sticky-module模块
2018-04-16 20:34 1924在使用负载均衡的时候会遇到会话保持的问题,常用的方法有: 1. ... -
dubbo源码学习(四):暴露服务的过程
2018-04-14 11:38 951dubbo采用的nio异步的通信,通信协议默认为 netty, ... -
dubbo源码学习(四)初始化过程细节:解析服务
2018-04-12 20:32 585今天将真正去看dubbo内部的实现过程,看dubbo的源码前我 ... -
dubbo源码学习(二) : spring 自定义标签
2018-04-09 20:29 597做dubbo的配置时很容易发现,dubbo有一套自己的标签,提 ... -
Dubbo多注册中心和Zookeeper服务的迁移
2018-04-06 08:58 1468一、Dubbo多注册中心 1、 应用场景 例如阿里有些服务 ... -
dubbo源码学习一:基础知识及使用的相关技术
2018-04-05 20:10 652Dubbo是Alibaba开源的分布式服务框架,它最大的特点是 ... -
worker模式
2018-03-29 20:16 601今天来学学,大家也好对线程池有一个更好的理解。 public ... -
线程各种状态转移分析
2018-03-28 22:13 871线程在它的生命周期 ... -
生产者-消费者模式实现
2018-03-26 22:45 1133生产者是指:生产数据的线程 消费者是指:使用数据的线程 生产者 ... -
java并发之同步辅助类Phaser
2018-03-19 21:46 1053Phaser含义: 更加复杂和强大的同步辅助类。它允许并发执 ... -
java并发之同步辅助类CyclicBarrier
2018-03-18 20:13 782CyclicBarrier含义: 栅栏允许两个或者多个线程在 ... -
java并发之同步辅助类semaphore
2018-03-14 21:24 746semaphore(seməˌfôr)含义: 信号量就是可以 ... -
Tomcat 集群 文件上传下载的共享问题 NFS配置
2018-03-12 21:50 626Tomcat 集群时上传文件时如何使得多部tomcat中的文件 ... -
it技术谱图分享
2018-03-10 22:05 4901、程序开发语言综述 2、前端工程师必备技能 3、 ...
相关推荐
java swt自定义控件java swt自定义控件java swt自定义控件java swt自定义控件
SWT自带的DateTime控件属实不好用,而且无法绑定到其他控件上。因此自己写一个日历控件用着方便,功能大致如下: 1、日历控件可自定义设置常见的几种日期格式; 2、可以绑定注册到其他控件如:文本框、按钮、标签上...
Java使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的...
一个SWT日期时间选择控件类,可方便地加入到自己的代码中,支持拖放
Java将HTML代码转图片 java内嵌浏览器需要用到的包 DJNativeSwing.jar DJNativeSwing-SWT.jar 以及32位SWT.jar
Java内嵌浏览器eclipse.swt插件版 swt-3.5M4-win32-win32-x86 eclipse.swt 源码,jar包 demo eclipse工程实例
swt自定义封装的日期时间选择控件,支持选择日期和时间
java浏览器控件 swt.jar 下载
只要swt一个jar包即可,无需jacob,jna,jni等等,方法很简单
SWT Browser(内嵌浏览器)所需SWTResourceManager Jar包
DJNativeSwing-SWT组件-Java GUI中内嵌浏览器相关JAR包
SWT/JFACE的控件库毕竟有限,在应用开发是我们不可避免地要自己开发一些自定义的控件
SWT实例,java开发应用,简单实用,适用于初学者
局域网聊天 SWT Java QQ 多线程的处理已经解决 非常好的学习资料
简单的SWT java,上传这个纯属为了获得积分
Java界面开发的SWT包,64位,不解压导入到eclipse中
SWT是JAVA里流行的图形界面开发工具 这里提供SWT API 文档 可以方便SWT 的使用
NULL 博文链接:https://lifei114.iteye.com/blog/827368
DJNativeSwing.jar,DJNativeSwing-SWT.jar,swt(Mac用.jar,swt(Window.jar 可解决问题:1.报错信息为缺少swt-cocoa-4335.dll和swt-cocoa.dll文件