Java 将SWT ScrolledComposite与EclipseJFace向导页面一起使用

Java 将SWT ScrolledComposite与EclipseJFace向导页面一起使用,java,eclipse,swt,jface,wizard,Java,Eclipse,Swt,Jface,Wizard,我想将scrolledComposite添加到Eclipse插件中的向导页面。在我实现scrolledComposite的第一页,一切都很好。问题是,之后显示的第二页是空白的 第一页的初始化代码: SecondPage createControl代码是标准的,但我也尝试了定位父级,这将是一个卷轴-我想这将是嵌套的ScrolledComposite的问题-如下所示: ScrolledComposite scroll = null; if(parent.getChildren() !=

我想将scrolledComposite添加到Eclipse插件中的向导页面。在我实现scrolledComposite的第一页,一切都很好。问题是,之后显示的第二页是空白的

第一页的初始化代码:

SecondPage createControl代码是标准的,但我也尝试了定位父级,这将是一个卷轴-我想这将是嵌套的ScrolledComposite的问题-如下所示:

    ScrolledComposite scroll = null;
 if(parent.getChildren() != null && parent.getChildren().length > 1 && parent.getChildren()[1] instanceof ScrolledComposite) { 
  scroll = (ScrolledComposite)parent.getChildren()[1]; 

 } 

    scroll.setLayoutData(new GridData(GridData.FILL_VERTICAL)); 
    Composite container = new Composite(scroll, SWT.NULL); 
    scroll.setContent(container);
    scroll.setAlwaysShowScrollBars(false);   
    scroll.setExpandVertical(true); 
    scroll.setExpandHorizontal(true); 

    scroll.setMinHeight(500);  
    scroll.setLayout(new GridLayout(1, false)); 


    GridLayout layout = new GridLayout();
    container.setLayout(layout); 
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
但这种方法不起作用


有没有人有过与ScrolledComposites和多页JFace向导集成的经验?

如果您看到类层次结构IDialogPage->DialogPage->WizardPage->YourCustomPage。因此,对于每个页面,您都需要在父组合下创建自定义内容,该内容由向导跨向导页面共享

但是,您正在将ScollableComposite添加到这个根组合的顶部,根组合是您案例中的内容元素,特定于第一个页面,并且不应共享到第二个向导页面


因此,您需要为第二页创建一个新的ScollableComposite,并单独添加内容。如果您尝试在第二页中更新同一个ScollableComposite的内容,那么当您单击“上一步”按钮时,您的内容将不会更新到第一页。因为调用getPreviousPage时不会调用createContent。

我找到了解决方案,但——我必须承认——这是一个非常愚蠢的错误。更改setControlcontainer就足够了;设置ControlScroll。现在每个页面都正确显示了。请以后注意以下事项:

在第二页使用与第一页相同的代码。
    ScrolledComposite scroll = null;
 if(parent.getChildren() != null && parent.getChildren().length > 1 && parent.getChildren()[1] instanceof ScrolledComposite) { 
  scroll = (ScrolledComposite)parent.getChildren()[1]; 

 } 

    scroll.setLayoutData(new GridData(GridData.FILL_VERTICAL)); 
    Composite container = new Composite(scroll, SWT.NULL); 
    scroll.setContent(container);
    scroll.setAlwaysShowScrollBars(false);   
    scroll.setExpandVertical(true); 
    scroll.setExpandHorizontal(true); 

    scroll.setMinHeight(500);  
    scroll.setLayout(new GridLayout(1, false)); 


    GridLayout layout = new GridLayout();
    container.setLayout(layout); 
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));