ScrolledComposite 滚动面版Demo

package org.ws.taobao.test;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class bb {
 
  public static void main(String[] args) {  
   Display display = new Display();    
         Shell shell = new Shell(display);  
         shell.setLayout(new FillLayout());   
         final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL  
                 | SWT.V_SCROLL | SWT.BORDER); 
         final Composite c1 = new Composite(sc1, SWT.NONE);  
         sc1.setContent(c1);   
         GridLayout layout = new GridLayout();  
         layout.numColumns = 1;  
         c1.setLayout(layout);  
         for(int i=0;i<50;i++)
         {
            Button b2 = new Button(c1, SWT.PUSH);  
               b2.setText("first button"+i);
              
         }
         c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
         shell.setSize(400, 300);
//         c1.layout(); 
          
         shell.open();  
         while (!shell.isDisposed()) {  
             if (!display.readAndDispatch())  
                 display.sleep();  
         }  
         display.dispose();  
  }

}

你可能感兴趣的:(ScrolledComposite 滚动面版Demo)