简体   繁体   English

如何在 Eclipse 中强制 JFace 向导的最小高度?

[英]How to force a minimum height of a JFace Wizard in Eclipse?

I'm presenting a wizard (code here ) that gets too low, so the content does not show completely (see screenshot below):我正在展示一个太低的向导( 此处的代码),因此内容无法完全显示(请参见下面的屏幕截图):

在此处输入图像描述

How can I force the wizard to have a minimum height?如何强制向导具有最小高度?

According to the answer on this question here on StackOverflow , the wizard will be the same height as the largest wizardpage in the wizard, but my wizard obvilusly does not get resized according to at least the content of the largest page, and I also tried to set the minimum height of the first visible wizard page with code like this in the WizardPage class:根据StackOverflow 上这个问题的答案,向导将与向导中最大的向导页面高度相同,但我的向导显然不会根据至少最大页面的内容调整大小,我也尝试过在 WizardPage class 中使用如下代码设置第一个可见向导页面的最小高度:

@Override
public void createControl(Composite parent) {
  // create the composite to hold the widgets
  Composite composite =  new Composite(parent, SWT.NULL);
  composite.setSize(300, 1024); // TODO: Does this work?

  GridData gridData = new GridData(300, 1024);
  gridData.heightHint = 1024;
  gridData.minimumHeight = 1024;
  composite.setLayoutData(gridData);

... but without success so far. ...但到目前为止还没有成功。

Any hints?有什么提示吗?

Try to set尝试设置

parent.setLayout(new GridLayout());

to your createControl() implementation of your first page.到您的第一页的createControl()实现。

It appears the parent you get in that method has an instance of PageContainerFillLayout as layout, not GridLayout .看来您在该方法中获得的父级具有PageContainerFillLayout的实例作为布局,而不是GridLayout

If you have access to your WizardDialog, you could also call如果您有权访问您的 WizardDialog,您也可以调用

wizardDialog.setMinimumPageSize(300, 1024)

you can use this codes below:您可以使用以下代码:

parent.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent event) { parent.setSize(parent.computeSize(490, 320)); } });

I just had a very similar problem (on Windows): A wizard where the wizard page had no message was not shown completely.我刚刚遇到了一个非常相似的问题(在 Windows 上):没有完全显示向导页面没有消息的向导。 What quickly solved it for me was to just add a message with a single space in the wizard page constructor:为我快速解决的方法是在向导页面构造函数中添加一个带有单个空格的消息:

class Page extends WizardPage {

    Page() {
        super("page.id", "Page title", null);
        setMessage(" ");

The accepted answer did not work for me (the wizard has quite some fields).接受的答案对我不起作用(向导有很多字段)。

You may need to specify a height hint for the GridData.您可能需要为 GridData 指定高度提示。

Alternatively, you could use a three column GridLayout and get all the rows after the first to span columns 2 and 3. I tend to use GridLayout and haven't had this problem before.或者,您可以使用三列 GridLayout 并获取第一列之后的所有行以跨越第 2 列和第 3 列。我倾向于使用 GridLayout 并且以前没有遇到过这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM