Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public static void main(String[] args) {
  2. final Display display = new Display();
  3. final Shell shell = new Shell(display);
  4. shell.setLayout(new FillLayout());
  5.  
  6. // Create the ScrolledComposite to scroll horizontally and vertically
  7. ScrolledComposite scrolledComp = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
  8.  
  9. // Create a child composite for your content
  10. Composite content = new Composite(scrolledComp, SWT.NONE);
  11. content.setLayout(new FillLayout());
  12.  
  13. // Create some content
  14. new Button(content, SWT.PUSH).setText("Button1");
  15. new Button(content, SWT.PUSH).setText("Button2");
  16.  
  17. // add content to scrolled composite
  18. scrolledComp.setContent(content);
  19.  
  20. // Set the minimum size (in this case way too large)
  21. scrolledComp.setMinSize(400, 400);
  22.  
  23. // Expand both horizontally and vertically
  24. scrolledComp.setExpandHorizontal(true);
  25. scrolledComp.setExpandVertical(true);
  26.  
  27. shell.pack();
  28. shell.open();
  29. while (!shell.isDisposed()) {
  30. if (!display.readAndDispatch()) {
  31. display.sleep();
  32. }
  33. }
  34. display.dispose();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement