swt与open flash chart

本文介绍了一种使用Eclipse SWT将OpenFlashChart集成到应用程序的方法。通过具体代码示例,展示了如何加载并显示图表文件,为开发者提供了一个实用的参考案例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

昨天看了IBM网站上写到rcp中运行open flash chart觉得不错自己就试着写了一下。

package com.chart.test; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.ole.win32.OLE; import org.eclipse.swt.ole.win32.OleAutomation; import org.eclipse.swt.ole.win32.OleControlSite; import org.eclipse.swt.ole.win32.OleFrame; import org.eclipse.swt.ole.win32.Variant; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class ChartTest { /** * Launch the application * @param args */ public static void main(String[] args) { String file="D://我的文档//学习资料//SWT//open-flash-chart-2-Lug-Wyrm-Charmer//open-flash-chart.swf"; final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setSize(500, 375); shell.setText("SWT Application"); OleFrame oleFrame=new OleFrame(shell,SWT.NONE); oleFrame.setLayoutData(new GridData(GridData.FILL_BOTH)); OleControlSite controlSite = new OleControlSite(oleFrame, SWT.NONE, "ShockwaveFlash.ShockwaveFlash"); /** * doVerb() Requests that the OLE Document or ActiveX Control * perform an action; actions are almost always changes to the activation state. */ controlSite.doVerb(OLE.OLEIVERB_SHOW); // // final OleAutomation automation = new OleAutomation(controlSite); /** * getIDsOfNames()得到控件方法对应的 id 值 */ int[] methodIDs = automation.getIDsOfNames(new String[] { "LoadMovie" }); System.out.println(methodIDs.length); System.out.println("methodIDs[0]="+methodIDs[0]); Variant[] methodArgs = { new Variant(0), new Variant(file+"?data-file=/bar-3d.txt") }; System.out.println(methodArgs.length); automation.invoke(methodIDs[0], methodArgs); shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值