2014-02-27 29 views
0

請幫助我,我是SWT的原始人。 我想將CTabFolder放在另一個CTabFolder內。 我已經嘗試了下面的代碼,但它的不完整。我如何將CtabFolder放置在SWT中的另一個CTabfolder內

import org.eclipse.swt.SWT; 
import org.eclipse.swt.custom.CTabFolder; 
import org.eclipse.swt.custom.CTabItem; 
import org.eclipse.swt.custom.SashForm; 
import org.eclipse.swt.widgets.Button; 
import org.eclipse.swt.widgets.Composite; 
import org.eclipse.swt.widgets.Control; 
import org.eclipse.swt.widgets.Display; 
import org.eclipse.swt.widgets.Group; 
import org.eclipse.swt.widgets.Shell; 
import org.eclipse.swt.widgets.Table; 
import org.eclipse.swt.widgets.TableItem; 
import org.eclipse.swt.widgets.Text; 
import org.eclipse.swt.SWT; 
import org.eclipse.swt.custom.CTabFolder; 
import org.eclipse.swt.custom.CTabItem; 
import org.eclipse.swt.events.*; 
import org.eclipse.swt.graphics.*; 
import org.eclipse.swt.layout.*; 
import org.eclipse.swt.widgets.*; 
import sun.awt.HorizBagLayout; 

    public class LayoutExample2 
    { 

    public static void main(String[] args) { 

     Display display=new Display(); 
     Shell shell=new Shell(display); 
     shell.setLayout(new GridLayout()); 

     CTabFolder ctf_main=new CTabFolder(shell,SWT.RIGHT_TO_LEFT); 
     CTabItem ctb1=new CTabItem(ctf_main,SWT.NONE); 
     ctf_main.setSimple(false); 
     ctf_main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); 
     ctf_main.pack(); 
     ctb1.setText("Error Management Portal  "); 

     CTabFolder ctf_inner=new CTabFolder(ctf_main,SWT.RIGHT_TO_LEFT); 
     CTabItem tbi1=new CTabItem(ctf_main,SWT.FLAT); 
     tbi1.setText("Search "); 


      shell.setMaximized(true); 
      shell.pack(); 
      shell.open(); 

     while (!shell.isDisposed()) { 
      if (!display.readAndDispatch()) { 
       display.sleep(); 
      } 
     } 
     display.dispose(); 
    } 
    } 

請幫我把Ctabfolder內的另一個Ctabfolder ...

回答

1

我看到這些問題:

你內心CTabItemtbi1有錯誤的母公司,它應該有內部的文件夾作爲其親本:

CTabItem tbi1 = new CTabItem(ctf_inner, SWT.FLAT); 

您需要告訴CTabItem關於它的控制與CTabItem.setControl()方法。所以外卡具有內部文件夾作爲其控制:

ctb1.setControl(ctf_inner); 

你可能還需要創建內部文件夾的子把事情以正確顯示:

Composite innerComp = new Composite(ctf_inner, SWT.NONE); 

tbi1.setControl(innerComp); 
+0

我敢肯定' CTabItem'沒有'setContent()'方法。 –

相關問題