Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » composite.setVisible(false) taking up space
composite.setVisible(false) taking up space [message #445880] Thu, 11 November 2004 15:55 Go to next message
Maureen Kraft is currently offline Maureen KraftFriend
Messages: 11
Registered: July 2009
Junior Member
I would like to set a control invisible such that it not only doesn't
appear but also no longer takes up space on its parent composite.

I am trying the following without luck.

m_parent.getDisplay().asyncExec(new Runnable()
{
public void run()
{
child.setVisible(false);
child.pack();
child.redraw();
child.getParent().pack();
child.getParent().redraw();
}
});

The child becomes invisible but still takes up the space that it had
allocated on the parent. Do I need to actually dispose of the child to get
it to free up its space?
Re: composite.setVisible(false) taking up space [message #445885 is a reply to message #445880] Thu, 11 November 2004 16:51 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Currently, yes you need to dispose of the widget.

See:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=49426

"Moe" <maureen_kraft@us.ibm.com> wrote in message
news:cn020u$jsi$1@eclipse.org...
>I would like to set a control invisible such that it not only doesn't
>appear but also no longer takes up space on its parent composite.
> I am trying the following without luck.
> m_parent.getDisplay().asyncExec(new Runnable()
> {
> public void run()
> {
> child.setVisible(false);
> child.pack();
> child.redraw();
> child.getParent().pack();
> child.getParent().redraw();
> }
> });
>
> The child becomes invisible but still takes up the space that it had
> allocated on the parent. Do I need to actually dispose of the child to get
> it to free up its space?
>
>
Re: composite.setVisible (false) taking up space [message #445914 is a reply to message #445880] Thu, 11 November 2004 19:19 Go to previous message
Dimitry Fayerman is currently offline Dimitry FayermanFriend
Messages: 14
Registered: July 2009
Junior Member
I was struggling with the same problem.
Disposing is very inconvenient especially if you have a complex layout and you want the control to show up in a certain space when is made visible again.

I solved the problem by overriding computeSize on the composite as follows:

public Point computeSize(int wHint, int hHint, boolean changed) {
if (!isVisible()) {
return new Point(0,0);
} else {
return super.computeSize(wHint, hHint, changed);
}
}

I think this issue should be addressed by the SWT development group cause is causes a lot of headaches.
Previous Topic:set cursor to Sash from SashForm
Next Topic:Executable jar for SWT standalone
Goto Forum:
  


Current Time: Thu Apr 25 19:31:22 GMT 2024

Powered by FUDForum. Page generated in 0.03665 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top