简体   繁体   中英

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:

@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.

It appears the parent you get in that method has an instance of PageContainerFillLayout as layout, not GridLayout .

If you have access to your WizardDialog, you could also call

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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