Eclipse plugin SWT组合显示在右侧
我正在为eclipse开发一个带有视图的插件,我需要使这个视图可滚动。我找到了如何使其可滚动,但复合显示在视图的右侧。如何填充所有视图 我的代码:Eclipse plugin SWT组合显示在右侧,eclipse-plugin,swt,Eclipse Plugin,Swt,我正在为eclipse开发一个带有视图的插件,我需要使这个视图可滚动。我找到了如何使其可滚动,但复合显示在视图的右侧。如何填充所有视图 我的代码: public class Comp2 extends Composite { public Comp2(Composite parent, int style) { super(parent, SWT.NONE); final ScrolledComposite sc = new ScrolledCompo
public class Comp2 extends Composite {
public Comp2(Composite parent, int style) {
super(parent, SWT.NONE);
final ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
sc.setLayout(new FillLayout());
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
final Composite subContainer = new Composite(sc, SWT.NONE);
Button btnNewButton = new Button(subContainer, SWT.NONE);
btnNewButton.setBounds(75, 99, 90, 30);
btnNewButton.setText("New Button");
Button btnNewButton_1 = new Button(subContainer, SWT.NONE);
btnNewButton_1.setBounds(357, 398, 90, 30);
btnNewButton_1.setText("New Button");
sc.setContent(subContainer);
sc.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle r = sc.getClientArea();
sc.setMinSize(subContainer
.computeSize(r.width, SWT.DEFAULT));
}
});
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
由于您正在扩展
Composite
该Composite正在将其正常体添加到父体。然后将一个ScrolledComposite
添加到父项中,使其位于第一个复合项旁边
您可以通过更改其父项将滚动组合
放入组合
:
super(父级,SWT.NONE);
//这个组合需要一个布局
setLayout(新的FillLayout());
//ScrolledComposite的父级是此复合
ScrolledComposite sc=新的ScrolledComposite(这是SWT.H|u SCROLL | SWT.V|u SCROLL);
谢谢!现在没事了!