如何改变控制SWT的位置?

时间:2013-05-08 13:35:03

标签: java swt

我是SWT的新手

我尝试创建滚动条和两个按钮

按钮布局不正确的问题。

我希望滚动条位于正确的位置,按钮将靠近滚动条

    Composite composite= new Composite(parent, SWT.NONE);
    GridLayout layout= new GridLayout(1, false);
    layout.marginHeight= 0;
    layout.marginWidth= 0;
    layout.horizontalSpacing= 0;
    layout.verticalSpacing= 0;
    composite.setLayout(layout);

    fComposite= new Composite(composite, SWT.NONE);
    GridData layoutData= new GridData(SWT.FILL, SWT.TOP, true, false);
    fComposite.setLayoutData(layoutData);
    layout= new GridLayout(1, false);
    layout.marginHeight= 0;
    layout.marginWidth= 0;
    layout.horizontalSpacing= 0;
    layout.verticalSpacing= 0;

    fComposite.setLayout(layout);


    Composite eComposite= new Composite(composite, SWT.NONE);
    eComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    FillLayout fillLayout= new FillLayout(SWT.VERTICAL);
    fillLayout.marginHeight= 0;
    fillLayout.marginWidth= 0;
    fillLayout.spacing= 0;

    eComposite.setLayout(fillLayout);


    Display display = parent.getDisplay();
    Shell shell = parent.getShell(); 
    Button button = new Button(fComposite, SWT.RIGHT_TO_LEFT);
    button.setText("Left"); //$NON-NLS-1$
    button.setImage(display.getSystemImage(SWT.ICON_ERROR));    


    final Scale scale = new Scale (fComposite, SWT.BORDER);
    Rectangle clientArea = fComposite.getClientArea ();
    scale.setBounds (clientArea.x, clientArea.y, 200, 64);
    scale.setMaximum (4);
    scale.setPageIncrement (1);
    scale.setSelection(4);

    Button rButton = new Button(fZoomerComposite, SWT.RIGHT_TO_LEFT);
    rButton.setText("Right"); //$NON-NLS-1$
    rButton.setImage(display.getSystemImage(SWT.ICON_INFORMATION)); 


    scale.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
          }
        });     
![current control should move right and need to fix the buttons][1]    

0 个答案:

没有答案