Hiding SWT Controls

There are many ways to hide SWT widgets. First one comes to mind is setVisible method of control. But the disadvantage of it is, hidden widget will not released and can't be used by other widgets.
Another approach is.

You can use layout data. In case of GridLayout, you can use exclude specific widget from being drown on canvas. Eg,

 Composite comp = new Composite(shell, SWT.NONE);  
 comp.setLayout(new GridLayout(4, false));  
 Label hidenLabel = new Label (comp, SWT.NONE);  
 GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);  
 hidenLabel.setGridData(gridData );  
 //hide the button  
 gridData .exclude = true;  
 comp.pack();   

Comments

Popular posts from this blog

Comparison of Cloud Services

When to use Import-Package and Require-Bundle in Eclipse Plugin?