weixin_42208050
2008-06-24 18:55
浏览 294
已采纳

swt怎么给TabItem添加滚动条?

rt,帮我看看我的代码那里有问题,滚动条显示不出来

public class ProjectGUI extends Composite {

private Text textArea;
/**

  • Create the composite
  • @param parent
  • @param style */ public ProjectGUI(Composite parent, int style) { super(parent, style); setLayout(new FormLayout());

final TabFolder tabFolder = new TabFolder(this, SWT.NONE);
final FormData formData = new FormData();
formData.bottom = new FormAttachment(100, -5);
formData.right = new FormAttachment(100, -5);
formData.top = new FormAttachment(0, 5);
formData.left = new FormAttachment(0, 5);
tabFolder.setLayoutData(formData);

final TabItem tabText = new TabItem(tabFolder, SWT.NONE);
tabText.setText("文本编辑");

textArea = new Text(tabFolder, SWT.BORDER);
tabText.setControl(textArea);

final TabItem tabTable = new TabItem(tabFolder, SWT.NONE);
tabTable.setText("界面控制");

final TabFolder tabFolder_1 = new TabFolder(tabFolder, SWT.NONE);
tabTable.setControl(tabFolder_1);

final TabItem tabView = new TabItem(tabFolder_1, SWT.NONE);
tabView.setText("流程图");

final TabItem tabValues = new TabItem(tabFolder_1, SWT.NONE);
tabValues.setText("控制变量,总参数");

tabFolder_1.setLayout(new FillLayout());
final ScrolledComposite scrolledComposite = new ScrolledComposite(tabFolder_1, SWT.BORDER ¦ SWT.H_SCROLL ¦ SWT.V_SCROLL);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
PropertyPage pp = new PropertyPage(scrolledComposite, SWT.NONE);
scrolledComposite.setContent(pp);
tabValues.setControl(scrolledComposite);

final TabItem tabItem = new TabItem(tabFolder_1, SWT.NONE);
tabItem.setText("进口条件");

final TabItem tabItem_1 = new TabItem(tabFolder_1, SWT.NONE);
tabItem_1.setText("流路和附面层堵塞系数");

final TabItem tabItem_2 = new TabItem(tabFolder_1, SWT.NONE);
tabItem_2.setText("离散点计算站");

final TabItem tabItem_3 = new TabItem(tabFolder_1, SWT.NONE);
tabItem_3.setText("叶排参数");

final TabItem tabItem_4 = new TabItem(tabFolder_1, SWT.NONE);
tabItem_4.setText("流量比");
}

@Override
public void dispose() {
super.dispose();
}

@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}

}

另外我想用eclispe rpc做双击treeview的一项。就在界面中间打开一个文件这样的功能,谁知道怎么做,treeview的change事件如何调用jface的Action打开view。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • lggegegmail 2008-06-25 10:01
    已采纳

    解答4: 滚动条问题
    [code="java"] tabFolder_1.setLayout(new FillLayout());
    final ScrolledComposite scrolledComposite = new ScrolledComposite(tabFolder_1, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    // 下面的注掉,你就可以看到滚动条
    // scrolledComposite.setExpandHorizontal(true);
    // scrolledComposite.setExpandVertical(true);
    // PropertyPage 注掉,是因为我本地没有
    // PropertyPage pp = new PropertyPage(scrolledComposite, SWT.NONE);
    // scrolledComposite.setContent(pp);
    tabValues.setControl(scrolledComposite);

    // 下面的是给scrolledComposite添加一个composite作为它的content.等同于你的propertypage
    final Composite composite = new Composite(scrolledComposite, SWT.NONE);
    composite.setSize(474, 313);
    scrolledComposite.setContent(composite);[/code]

    打赏 评论
  • lggegegmail 2008-06-25 09:29

    解答1. treeViewer的双击问题.
    可以给treeViewer添加双击监听
    treeview.addDoubleClickListener(new IDoubleClickListener() {
    public void doubleClick(DoubleClickEvent event) {
    ...
    }
    });

    打赏 评论
  • lggegegmail 2008-06-25 09:32

    解答2: 调用JFace的Action问题.
    [code="java"]viewer.addDoubleClickListener(new IDoubleClickListener() {
    public void doubleClick(DoubleClickEvent event) {
    new TTAction().run();
    }
    });

    class TTAction extends Action {
    public void run() {
    System.out.println("TTACTIon");
    }
    }[/code]

    打赏 评论
  • lggegegmail 2008-06-25 09:54

    解答3: 打开ViewPart的问题
    [code="java"]
    String viewId = "....";
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(viewId);[/code]

    打赏 评论

相关推荐 更多相似问题