Sunday, September 5, 2010

SWT Layout developed with attention to items

Two days, leading team members to develop a useful interface complexity, as team members of the SWT's Layout is not very familiar with the interface has a lot of problems there. Some time is unusual, because the Layout and LayoutData do not match, sometimes it is not the screen display. Always, the problem can produce basically met. 

The current development thinking is the first painting with SWT Designer interface, and then hand reconstruction order, SWT Designer reconstructed the code for it can no longer identified. Therefore, visualization tools alone is not enough, but also very familiar with the coding on the SWT interface. So for SWT Layout of control is crucial. 


Composite are creating their own, be sure to pay attention to: 

1 out incoming Composite some only once, is super (parent, style); the time available, after his father, all the controls are the Composite itself. Do not use any other parts of the parent. Otherwise, the parent is likely to interfere with the content, resulting in self-and parent other controls inside an error. 

2, each container must have set the Composite Layout, or they might not reveal anything. In general are set GridLayout, if the Composite itself to place a control, for example, placed on a Table, it can also be used FillLayout.For starters, all recommended the use GridLayout, or prone to Layout and LayoutData mismatch, and if the interface is complex, the problem is hard to find. GridLayout can replace other Layout, to achieve a variety of needs (if any control overlap, they can not succeed, we must use FormLayout). 
Here is a source, recommended building the interface in this way. 
public class TestComposite extends Composite ... ( 

private Text text; 
/ ** *//** 
* Create the composite 
* @ Param parent 
* @ Param style 
* / 
public TestComposite (Composite parent, int style) ... ( 
super (parent, style); 
setLayout (new GridLayout ()); 
createArea (this); 
private void createArea (Composite parent )...{ 
text = new Text (this, SWT.BORDER); 
text.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); 

final Button button = new Button (this, SWT.NONE); 
button.setText ("button"); 

@ Override 
public void dispose () ... ( 
super.dispose (); 
)

No comments:

Post a Comment