java - How to hide an SWT composite so that it takes no space? -


i need hide composite (and children inside). setting setvisible(false) keep space of composite.

composite outer = new composite(parent, swt.none);       outer.setlayout(new gridlayout(1,false)); outer.setlayoutdata(new griddata(griddata.fill_both) );  composite comptohide = new mycomposite(outer, swt.none);         comptohide.setlayout(new gridlayout()); comptohide.setvisible(false); 

here code want. use griddata#exclude in combination control#setvisible(boolean) hide/unhide composite:

public static void main(string[] args) {     display display = new display();     final shell shell = new shell(display);     shell.settext("stackoverflow");     shell.setlayout(new gridlayout(1, true));      button hidebutton = new button(shell, swt.push);     hidebutton.settext("toggle");      final composite content = new composite(shell, swt.none);     content.setlayout(new gridlayout(3, false));      final griddata data = new griddata(swt.fill, swt.fill, true, true);     content.setlayoutdata(data);      for(int = 0; < 10; i++)     {         new label(content, swt.none).settext("label " + i);     }      hidebutton.addlistener(swt.selection, new listener()     {         @override         public void handleevent(event arg0)         {             data.exclude = !data.exclude;             content.setvisible(!data.exclude);             content.getparent().pack();         }     });      shell.pack();     shell.open();     while (!shell.isdisposed())     {         if (!display.readanddispatch())             display.sleep();     }     display.dispose(); } 

before hiding:

enter image description here

after hiding:

enter image description here


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -