我对SWT和JFace很新。我必须修复一个错误,我需要为复合添加滚动条。我尝试将其更改为Scrolled Composite并设置属性位,然后启用垂直和水平扩展,但无济于事。
FormToolkit tk = this.toolkit;
Composite consistencyCheckComposite;
this.consistencyCheckComposite = tk.createComposite(this.consistencyCheckSection );
//this.consistencyCheckComposite = new ScrolledComposite( this.parentComposite, SWT.V_SCROLL | SWT.H_SCROLL );
gd = new GridData( SWT.FILL, SWT.BEGINNING, true, true );
this.consistencyCheckComposite.setLayoutData( gd );
this.consistencyCheckComposite.setBackground( this.parentComposite.getBackground() );
GridLayout consistencyCheckGridLayout = new GridLayout();
consistencyCheckGridLayout.numColumns = 4;
consistencyCheckGridLayout.horizontalSpacing = DEFAULT_SPACING * 3; // 15
this.consistencyCheckComposite.setLayout( consistencyCheckGridLayout );
this.consistencyCheckComposite = tk.createComposite( this.consistencyCheckSection );
//this.consistencyCheckComposite = new ScrolledComposite( this.parentComposite, SWT.V_SCROLL | SWT.H_SCROLL );
gd = new GridData( SWT.FILL, SWT.BEGINNING, true, true );
this.consistencyCheckComposite.setLayoutData( gd );
this.consistencyCheckComposite.setBackground( this.parentComposite.getBackground() );
GridLayout consistencyCheckGridLayout = new GridLayout();
consistencyCheckGridLayout.numColumns = 4;
consistencyCheckGridLayout.horizontalSpacing = DEFAULT_SPACING * 3; // 15
this.consistencyCheckComposite.setLayout( consistencyCheckGridLayout );
答案 0 :(得分:0)
这里的问题可能与你的gridData最后两个参数有关,这些参数指的是grabExcessHorizontalSpace和grabExcessVerticalSpace。它可以根据复合内容改变合成大小。您应该创建一个修复大小的复合。
您的代码不够清晰,无法说明问题。尝试提供更详细的代码。