A Kumar
A Kumar

Reputation: 123

Hiding SWT Controls

How we can hide the SWT controls? I know setVisible() method of control class can be used. But the disadvantage of it is, hidden widget will not released and can't be used by other widgets.

Is there any other approach which can be adopted?

Upvotes: 4

Views: 426

Answers (1)

Shashwat
Shashwat

Reputation: 2352

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

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(); 

Upvotes: 5

Related Questions