0

I created a Composite (SWT) with two objects: Label and Text.

In some cases I don't want to see these widgets. When I press a button I want to hide the composite.

Do I have option to hide the composite so it won't hold place on the screen? (I don't want to see empty rows, I have other objects beside them)

How I can do it?

    Composite comp = new Composite(shell, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;

Label label = new Label(comp , SWT.BORDER);
label.setText("This is a label:");
label.setToolTipText("This is the tooltip of this label");

Text text = new Text(comp , SWT.NONE);
text.setText("This is the text in the text widget");
text.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
text.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
m4tx
  • 4,139
  • 5
  • 37
  • 61
user1365697
  • 5,819
  • 15
  • 60
  • 96

1 Answers1

1

You can use the dispose() method to remove the Composite. But then you have to create the Composite again if you want to show it again.

Edit:

Well or just use the solution Baz posted. This is a better way...

Baz
  • 36,440
  • 11
  • 68
  • 94
Joschua
  • 69
  • 4
  • Hiding is very different paradigm than disposing, especially for more complicated widgets that may have other children, etc. This should not be recommended. – Krease Feb 08 '14 at 05:00