2011-06-18 11 views
0

Eclipse SWTで作業を始めていますが、次の質問があります。Eclipse SWT Shell to JInternalFrame

次のクラスでは、「archivo」変数で参照されるドキュメントという名前のウィンドウが開きます。

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(); 
    } 
} 

どうすればそのウィンドウをJInternalFrameにすることができますか?

ありがとうございました。 よろしくお願いいたします。

答えて

1

2つのツールキットが混在しています。あなたのコードはSWTを使用していますが、JInternalFrameはSwingツールキットから来ています。 SWTとSwingは、JavaでUIをコーディングする方法とはまったく異なる2つの方法です。

There are some possibilities about how to integrate SWT and Swingしかし、SWT WindowをJInternalFrameに「変換する」ことはできません。それ以外の場合、Windowは実際のウィンドウを表し、JInternalFrameはSwingの軽量オブジェクトと呼ばれ、OSレベルのウィンドウは表しません。

関連する問題