Java Eclipse SWT外壳至JInternalFrame
我开始使用EclipseSWT,我有以下问题 下一个类打开一个窗口,其中“archivo”变量中引用了word文档Java Eclipse SWT外壳至JInternalFrame,java,eclipse,swt,Java,Eclipse,Swt,我开始使用EclipseSWT,我有以下问题 下一个类打开一个窗口,其中“archivo”变量中引用了word文档 import java.io.File; import javax.swing.JInternalFrame; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.ole.win3
import java.io.File;
import javax.swing.JInternalFrame;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
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 ArchivoMSOffice {
protected static OleClientSite clientSite;
protected static OleFrame frame;
public ArchivoMSOffice() {
}
public void run(archivo) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setText(archivo);
shell.setLayout(new FillLayout());
try {
frame = new OleFrame(shell, SWT.NONE);
//esto abre un documento existente
clientSite = new OleClientSite(frame, SWT.NULL, new File(archivo));
} catch (SWTError e) {
System.out.println("Unable to open activeX control");
display.dispose();
return;
}
shell.setSize(800, 600);
shell.open();//this open de Window
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
我该怎么做才能使那扇窗户成为一个金框呢
谢谢你的帮助。
你好 您正在混合使用两个工具包。您的代码正在使用SWT,但是
JInternalFrame
来自Swing工具包。SWT和Swing是用Java编写UI的两种完全不同的方法
,但恐怕您不能将SWT窗口“转换”为JInternalFrame。若并没有其他原因,Window代表屏幕上的真实窗口,而JInternalFrame是Swing中的所谓轻量级对象,它并不代表操作系统级别的窗口