Start with the upper-left button, attach the top and left edges to the window, offsetting by five pixels: : 表单布局 « SWT « Java 教程

En
Java 教程
1. 语言基础
2. 数据类型
3. 操作符
4. 流程控制
5. 类定义
6. 开发相关
7. 反射
8. 正则表达式
9. 集合
10. 线
11. 文件
12. 泛型
13. 本土化
14. Swing
15. Swing事件
16. 二维图形
17. SWT
18. SWT 二维图形
19. 网络
20. 数据库
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web服务SOA
27. EJB3
28. Spring
29. PDF
30. 电子邮件
31. 基于J2ME
32. J2EE应用
33. XML
34. 设计模式
35. 日志
36. 安全
37. Apache工具
38. 蚂蚁编译
39. JUnit单元测试
Java
Java 教程 » SWT » 表单布局 
17. 94. 18. Start with the upper-left button, attach the top and left edges to the window, offsetting by five pixels:
Start with the upper-left button, attach the top and left edges to the window,  offsetting by five pixels:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class FormLayoutFormAttachmentSetButton {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 10;
    shell.setLayout(layout);

    Button one = new Button(shell, SWT.PUSH);
    one.setText("One");
    FormData data = new FormData();
    data.top = new FormAttachment(05);
    data.left = new FormAttachment(05);
    data.bottom = new FormAttachment(50, -5);
    data.right = new FormAttachment(50, -5);
    one.setLayoutData(data);    
    
    
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}
17. 94. 表单布局
17. 94. 1. 使用FormLayouts
17. 94. 2. FormLayout :左,右边缘
17. 94. 3. FormLayoutFormLayout
17. 94. 4. FormData对象和FormAttachment对象FormData对象和FormAttachment对象
17. 94. 5. FormData:宽度和高度FormData:宽度和高度
17. 94. 6. FormLayout:间距
17. 94. 7. 配置每一方向
17. 94. 8. Attaching a Control to a Position in the Parent CompositeAttaching a Control to a Position in the Parent Composite
17. 94. 9. Specify the offset of the control side from the attachment positionSpecify the offset of the control side from the attachment position
17. 94. 10. 没有FormAttachment对象没有FormAttachment对象
17. 94. 11. 指定附件四面控制。指定附件四面控制。
17. 94. 12. Attaching a Control to Another Control
17. 94. 13. Attaching to the Adjacent Side of Another ControlAttaching to the Adjacent Side of Another Control
17. 94. 14. Attaching to the Specified Side of Another ControlAttaching to the Specified Side of Another Control
17. 94. 15. Center a control on another controlCenter a control on another control
17. 94. 16. 中心控制横向和纵向中心控制横向和纵向
17. 94. 17. 使用FormLayout布局对话框使用FormLayout布局对话框
17. 94. 18. Start with the upper-left button, attach the top and left edges to the window, offsetting by five pixels:Start with the upper-left button, attach the top and left edges to the window,  offsetting by five pixels:
17. 94. 19. To create the upper-right three buttons, you reason that you can put them all in a composite with a grid layout, and attach the composite to your first button:To create the upper-right three buttons, you reason that you can put them all in a composite with a grid layout, and attach the composite to your first button:
17. 94. 20. Attach the bottom button to the upper-left button and the window:Attach the bottom button to the upper-left button and the window:
17. 94. 21. FormLayout复合FormLayout复合
17. 94. 22. FormLayout example snippet: create a simple dialog using form layoutFormLayout example snippet: create a simple dialog using form layout
17. 94. 23. FormLayout example snippet: center a label and single line text using a form layoutFormLayout example snippet: center a label and single line text using a form layout
17. 94. 24. FormLayout example snippet: create a simple OK/CANCEL dialog using form layoutFormLayout example snippet: create a simple OK/CANCEL dialog using form layout
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.