FormData: width and height : FormLayout « SWT « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web Services SOA
27. EJB3
28. Spring
29. PDF
30. Email
31. J2ME
32. J2EE Application
33. XML
34. Design Pattern
35. Log
36. Security
37. Apache Common
38. Ant
39. JUnit
Java
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Tutorial » SWT » FormLayout 
17. 94. 5. FormData: width and height

Set the preferred width and height of the control.

FormData: width and height
import org.eclipse.swt.SWT;
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 FormLayoutFormDataWidthHeight {
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);

    shell.setLayout(new FormLayout());

    FormData formData = new FormData();
    formData.width = 100;
    formData.height = 200;

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");
    button1.setLayoutData(formData);

    shell.setSize(450400);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}
17. 94. FormLayout
17. 94. 1. Using FormLayouts
17. 94. 2. FormLayout: attach with left and right margin
17. 94. 3. FormLayout: attach each otherFormLayout: attach each other
17. 94. 4. FormData Objects and FormAttachment ObjectsFormData Objects and FormAttachment Objects
17. 94. 5. FormData: width and heightFormData: width and height
17. 94. 6. FormLayout: spacing
17. 94. 7. To configure the attachment of each side
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. Without FormAttachment objectsWithout FormAttachment objects
17. 94. 11. Specify attachments for all four sides of a control.Specify attachments for all four sides of a control.
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. Center control both horizontally and verticallyCenter control both horizontally and vertically
17. 94. 17. Use FormLayout to layout a dialogUse FormLayout to layout a dialog
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 ComplexFormLayout Complex
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 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.