0
我正在開發一個帶有視圖的eclipse插件,我需要使這個視圖可以滾動。我發現如何讓它滾動,但複合出現在視圖的右側。如何填寫所有視圖?SWT Composite出現在右邊
我的代碼:
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
}
}
感謝的!現在可以了! –