Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Hiding Table
Hiding Table [message #375153] |
Thu, 02 October 2003 13:51  |
Eclipse User |
|
|
|
Hi,
I have a Table in a composite with GridLayout. Now I want to hide it.
So I do "table.setVisible(false)" and then "shell.pack(true)" (because I
want the dialog resized). I also do a
((GridData)table.getLayoutData()).heightHint = 0 for hiding.
Now the table still occupies its place (well its not as big as it was
before - the heightHint=0 makes it one row high) even though it's not
visible - meaning: the space is not occupied by another control
Peschmä
|
|
| | | | |
Re: Hiding Table [message #375186 is a reply to message #375180] |
Sat, 04 October 2003 02:56   |
Eclipse User |
|
|
|
Hi,
I checked it out. It works.
I'd never come up with the idea of using moveBelow()/moveAbove() for the
needed purpose. The apidoc seems to be quite wrong - or at least it sounds
to me as if I was ordering the controls' position in z-axis direction...
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class Sample {
private Display display;
private Shell shell;
private Shell invisibleShell;
private Button b;
private Button b1, b2;
Sample() {
display = new Display();
shell = new Shell(display, SWT.DIALOG_TRIM);
invisibleShell = new Shell(display, SWT.NULL);
GridLayout gl = new GridLayout();
shell.setLayout(gl);
b1 = new Button(shell, SWT.NULL);
b1.setText("First; hide");
b1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
b.setParent(invisibleShell);
shell.pack(true);
}
}
);
b = new Button(shell, SWT.NULL);
b.setText("Middle");
b2 = new Button(shell, SWT.NULL);
b2.setText("Last; show");
b2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
b.setParent(shell);
b.moveBelow(b1);
shell.pack(true);
}
}
);
shell.pack();
shell.open();
while(!shell.isDisposed())
display.readAndDispatch();
}
public static void main(String[] args) {
new Sample();
}
}
[/snipp]
Peschmä
Am Fri, 03 Oct 2003 22:35:01 +0200 schrieb Simon Rutishauser:
> Thanks
>
> I've been doing such games for a while. (In my case I used a FormLayout
> and changed the FormAttachments every time
> :D, but here it grew too complicated)
>
> Sounds like an ugly workaround. But I can live with that.
>
> Thanks a lot
>
> Peschmä
>
> Am Fri, 03 Oct 2003 13:34:11 -0400 schrieb Emir Alikadic:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 03/10/2003 12:44, Simon Rutishauser wrote:
>> | Yes, it _should_ definitely be setVisible().
>> |
>> | But in my case a
>> | table.setVisible(false); shell.pack(true); causes the space where the
>> | table was to be grayed (like a composite with nothin in it) instead of
>> | being used for other controls.
>>
>> I've had a similar problem where I had to show or hide a Composite and I
>> used a Control#setParent and Control#moveBelow; I created a dummy Shell
>> which is never displayed which I set as a parent when I want to hide the
>> said Composite. To show it, I'd set the parent back to original and use
>> moveBelow to put it in the right place (you should call pack() on the
>> parent after that).
>>
>> There may be better ways to do it, but this one certainly works (app in
>> question has been in production for a while). - -- Emir Alikadic
>> Software Developer
>> CollectiveBid Systems Inc.
>>
>> "Our products just aren't engineered for security." ~ [Brian Valentine,
>> Senior VP Windows Division, Microsoft] -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.2.1 (MingW32)
>> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>>
>> iD8DBQE/fbMTuSy542G+Z7QRAhoxAJ4iDVOJFlUL1xIc9G8Nrs2Q0k3DCwCf dxFU
>> HTwMRndyYlLe9NoDvS03+no=
>> =GFzL
>> -----END PGP SIGNATURE-----
|
|
| |
Re: Hiding Table [message #375284 is a reply to message #375256] |
Tue, 07 October 2003 12:06   |
Eclipse User |
|
|
|
It works now.
I want the Shell to be resized. The other controls should remain about as
they are.
Using FormLayout is quite painful. Doing it with GridLayout and moving the
Table to an invisible Shell is easier.
It looks like this:
State 1: State2:
---------------- -------------
Some Controls Some Controls
---------------- -------------
Table Other Controls
----------------
Other Controls
Peschmä
Am Tue, 07 Oct 2003 10:13:14 -0400 schrieb Steve Northover:
> You are reordering the children. A better solution would probably be to
> use FormLayout and change the attachments. Can you post a more complete
> example, showing the effect that you are after? You mention that you want
> to hide a table. Do you want another widget to take it's place in the
> grid? Thanks.
>
> "Simon Rutishauser" <simon.rutishauser@gmx.ch> wrote in message
> news:pan.2003.10.04.06.56.55.788010@gmx.ch...
>> Hi,
>>
>> I checked it out. It works.
>>
>> I'd never come up with the idea of using moveBelow()/moveAbove() for the
>> needed purpose. The apidoc seems to be quite wrong - or at least it
>> sounds to me as if I was ordering the controls' position in z-axis
>> direction...
>>
>>
>> import org.eclipse.swt.*;
>> import org.eclipse.swt.events.*;
>> import org.eclipse.swt.widgets.*;
>> import org.eclipse.swt.layout.*;
>>
>> public class Sample {
>> private Display display;
>> private Shell shell;
>>
>> private Shell invisibleShell;
>>
>> private Button b;
>> private Button b1, b2;
>>
>> Sample() {
>> display = new Display();
>> shell = new Shell(display, SWT.DIALOG_TRIM);
>>
>> invisibleShell = new Shell(display, SWT.NULL);
>>
>> GridLayout gl = new GridLayout();
>> shell.setLayout(gl);
>>
>> b1 = new Button(shell, SWT.NULL);
>> b1.setText("First; hide");
>> b1.addSelectionListener(new SelectionAdapter() { public void
>> widgetSelected(SelectionEvent e) { b.setParent(invisibleShell);
>> shell.pack(true);
>> }
>> }
>> );
>>
>>
>> b = new Button(shell, SWT.NULL);
>> b.setText("Middle");
>>
>> b2 = new Button(shell, SWT.NULL);
>> b2.setText("Last; show");
>> b2.addSelectionListener(new SelectionAdapter() { public void
>> widgetSelected(SelectionEvent e) { b.setParent(shell);
>> b.moveBelow(b1);
>> shell.pack(true);
>> }
>> }
>> );
>>
>> shell.pack();
>>
>> shell.open();
>>
>> while(!shell.isDisposed())
>> display.readAndDispatch();
>> }
>> }
>> public static void main(String[] args) { new Sample();
>> }
>> }
>> [/snipp]
>>
>> Peschmä
>>
>> Am Fri, 03 Oct 2003 22:35:01 +0200 schrieb Simon Rutishauser:
>>
>> > Thanks
>> >
>> > I've been doing such games for a while. (In my case I used a
>> > FormLayout and changed the FormAttachments every time
>> > :D, but here it grew too complicated)
>> >
>> > Sounds like an ugly workaround. But I can live with that.
>> >
>> > Thanks a lot
>> >
>> > Peschmä
>> >
>> > Am Fri, 03 Oct 2003 13:34:11 -0400 schrieb Emir Alikadic:
>> >
>> >> -----BEGIN PGP SIGNED MESSAGE-----
>> >> Hash: SHA1
>> >>
>> >> On 03/10/2003 12:44, Simon Rutishauser wrote:
>> >> | Yes, it _should_ definitely be setVisible().
>> >> |
>> >> | But in my case a
>> >> | table.setVisible(false); shell.pack(true); causes the space where
>> >> | the table was to be grayed (like a composite with nothin in it)
>> >> | instead
> of
>> >> | being used for other controls.
>> >>
>> >> I've had a similar problem where I had to show or hide a Composite
>> >> and
> I
>> >> used a Control#setParent and Control#moveBelow; I created a dummy
>> >> Shell which is never displayed which I set as a parent when I want to
>> >> hide
> the
>> >> said Composite. To show it, I'd set the parent back to original and
> use
>> >> moveBelow to put it in the right place (you should call pack() on the
>> >> parent after that).
>> >>
>> >> There may be better ways to do it, but this one certainly works (app
>> >> in question has been in production for a while). - -- Emir Alikadic
>> >> Software Developer
>> >> CollectiveBid Systems Inc.
>> >>
>> >> "Our products just aren't engineered for security." ~ [Brian
>> >> Valentine, Senior VP Windows Division, Microsoft] -----BEGIN PGP
>> >> SIGNATURE----- Version: GnuPG v1.2.1 (MingW32)
>> >> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>> >>
>> >> iD8DBQE/fbMTuSy542G+Z7QRAhoxAJ4iDVOJFlUL1xIc9G8Nrs2Q0k3DCwCf dxFU
>> >> HTwMRndyYlLe9NoDvS03+no=
>> >> =GFzL
>> >> -----END PGP SIGNATURE-----
>>
>>
|
|
| |
Re: Hiding Table [message #375303 is a reply to message #375293] |
Thu, 09 October 2003 04:13   |
Eclipse User |
|
|
|
On which ones not?
I tested it on Win2k and Linux (with motif, gtk2 and fox) and all those
worked.
Peschmä
Am Wed, 08 Oct 2003 11:20:43 -0400 schrieb Steve Northover:
> The only reason I mention this is that Control.setParent() is not
> implemented on some platforms.
>
> "Simon Rutishauser" <simon.rutishauser@gmx.ch> wrote in message
> news:pan.2003.10.07.16.06.58.240580@gmx.ch...
>> It works now.
>>
>> I want the Shell to be resized. The other controls should remain about
>> as they are.
>> Using FormLayout is quite painful. Doing it with GridLayout and moving
>> the Table to an invisible Shell is easier.
>>
>> It looks like this:
>>
>> State 1: State2:
>>
>> ---------------- -------------
>> Some Controls Some Controls
>> ---------------- -------------
>> Table Other Controls
>> ----------------
>> Other Controls
>>
>> Peschmä
>>
>> Am Tue, 07 Oct 2003 10:13:14 -0400 schrieb Steve Northover:
>> > You are reordering the children. A better solution would probably be
>> > to use FormLayout and change the attachments. Can you post a more
>> > complete example, showing the effect that you are after? You mention
>> > that you
> want
>> > to hide a table. Do you want another widget to take it's place in the
>> > grid? Thanks.
>> >
>> > "Simon Rutishauser" <simon.rutishauser@gmx.ch> wrote in message
>> > news:pan.2003.10.04.06.56.55.788010@gmx.ch...
>> >> Hi,
>> >>
>> >> I checked it out. It works.
>> >>
>> >> I'd never come up with the idea of using moveBelow()/moveAbove() for
> the
>> >> needed purpose. The apidoc seems to be quite wrong - or at least it
>> >> sounds to me as if I was ordering the controls' position in z-axis
>> >> direction...
>> >>
>> >>
>> >> import org.eclipse.swt.*;
>> >> import org.eclipse.swt.events.*;
>> >> import org.eclipse.swt.widgets.*;
>> >> import org.eclipse.swt.layout.*;
>> >>
>> >> public class Sample {
>> >> private Display display;
>> >> private Shell shell;
>> >>
>> >> private Shell invisibleShell;
>> >>
>> >> private Button b;
>> >> private Button b1, b2;
>> >>
>> >> Sample() {
>> >> display = new Display();
>> >> shell = new Shell(display, SWT.DIALOG_TRIM);
>> >>
>> >> invisibleShell = new Shell(display, SWT.NULL);
>> >>
>> >> GridLayout gl = new GridLayout();
>> >> shell.setLayout(gl);
>> >>
>> >> b1 = new Button(shell, SWT.NULL);
>> >> b1.setText("First; hide");
>> >> b1.addSelectionListener(new SelectionAdapter() { public void
>> >> widgetSelected(SelectionEvent e) { b.setParent(invisibleShell);
>> >> shell.pack(true);
>> >> }
>> >> }
>> >> );
>> >>
>> >>
>> >> b = new Button(shell, SWT.NULL);
>> >> b.setText("Middle");
>> >>
>> >> b2 = new Button(shell, SWT.NULL);
>> >> b2.setText("Last; show");
>> >> b2.addSelectionListener(new SelectionAdapter() { public void
>> >> widgetSelected(SelectionEvent e) { b.setParent(shell);
>> >> b.moveBelow(b1);
>> >> shell.pack(true);
>> >> }
>> >> }
>> >> );
>> >>
>> >> shell.pack();
>> >>
>> >> shell.open();
>> >>
>> >> while(!shell.isDisposed())
>> >> display.readAndDispatch();
>> >> }
>> >> }
>> >> public static void main(String[] args) { new Sample();
>> >> }
>> >> }
>> >> [/snipp]
>> >>
>> >> Peschmä
>> >>
>> >> Am Fri, 03 Oct 2003 22:35:01 +0200 schrieb Simon Rutishauser:
>> >>
>> >> > Thanks
>> >> >
>> >> > I've been doing such games for a while. (In my case I used a
>> >> > FormLayout and changed the FormAttachments every time
>> >> > :D, but here it grew too complicated)
>> >> >
>> >> > Sounds like an ugly workaround. But I can live with that.
>> >> >
>> >> > Thanks a lot
>> >> >
>> >> > Peschmä
>> >> >
>> >> > Am Fri, 03 Oct 2003 13:34:11 -0400 schrieb Emir Alikadic:
>> >> >
>> >> >> -----BEGIN PGP SIGNED MESSAGE-----
>> >> >> Hash: SHA1
>> >> >>
>> >> >> On 03/10/2003 12:44, Simon Rutishauser wrote:
>> >> >> | Yes, it _should_ definitely be setVisible().
>> >> >> |
>> >> >> | But in my case a
>> >> >> | table.setVisible(false); shell.pack(true); causes the space
>> >> >> | where the table was to be grayed (like a composite with nothin
>> >> >> | in it) instead
>> > of
>> >> >> | being used for other controls.
>> >> >>
>> >> >> I've had a similar problem where I had to show or hide a Composite
>> >> >> and
>> > I
>> >> >> used a Control#setParent and Control#moveBelow; I created a dummy
>> >> >> Shell which is never displayed which I set as a parent when I want
> to
>> >> >> hide
>> > the
>> >> >> said Composite. To show it, I'd set the parent back to original
>> >> >> and
>> > use
>> >> >> moveBelow to put it in the right place (you should call pack() on
> the
>> >> >> parent after that).
>> >> >>
>> >> >> There may be better ways to do it, but this one certainly works
>> >> >> (app in question has been in production for a while). - -- Emir
>> >> >> Alikadic Software Developer
>> >> >> CollectiveBid Systems Inc.
>> >> >>
>> >> >> "Our products just aren't engineered for security." ~ [Brian
>> >> >> Valentine, Senior VP Windows Division, Microsoft] -----BEGIN PGP
>> >> >> SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) Comment: Using
>> >> >> GnuPG with Thunderbird - http://enigmail.mozdev.org
>> >> >>
>> >> >> iD8DBQE/fbMTuSy542G+Z7QRAhoxAJ4iDVOJFlUL1xIc9G8Nrs2Q0k3DCwCf dxFU
>> >> >> HTwMRndyYlLe9NoDvS03+no=
>> >> >> =GFzL
>> >> >> -----END PGP SIGNATURE-----
>> >>
>> >>
>> >>
>>
|
|
| |
Re: Hiding Table [message #375341 is a reply to message #375311] |
Fri, 10 October 2003 03:29  |
Eclipse User |
|
|
|
oops, you're right there. Well, I'll have to rethink this.
Peschmä
Am Thu, 09 Oct 2003 09:45:56 -0400 schrieb Steve Northover:
> Not implemented on Motif or Mac.
>
> "Simon Rutishauser" <simon.rutishauser@gmx.ch> wrote in message
> news:pan.2003.10.09.08.13.22.668475@gmx.ch...
>> On which ones not?
>>
>> I tested it on Win2k and Linux (with motif, gtk2 and fox) and all those
>> worked.
>>
>> Peschmä
>>
>> Am Wed, 08 Oct 2003 11:20:43 -0400 schrieb Steve Northover:
>> > The only reason I mention this is that Control.setParent() is not
>> > implemented on some platforms.
>> >
>> > "Simon Rutishauser" <simon.rutishauser@gmx.ch> wrote in message
>> > news:pan.2003.10.07.16.06.58.240580@gmx.ch...
>> >> It works now.
>> >>
>> >> I want the Shell to be resized. The other controls should remain
>> >> about as they are.
>> >> Using FormLayout is quite painful. Doing it with GridLayout and
>> >> moving the Table to an invisible Shell is easier.
>> >>
>> >> It looks like this:
>> >>
>> >> State 1: State2:
>> >>
>> >> ---------------- -------------
>> >> Some Controls Some Controls
>> >> ---------------- -------------
>> >> Table Other Controls
>> >> ----------------
>> >> Other Controls
>> >>
>> >> Peschmä
>> >>
>> >> Am Tue, 07 Oct 2003 10:13:14 -0400 schrieb Steve Northover:
>> >> > You are reordering the children. A better solution would probably
>> >> > be to use FormLayout and change the attachments. Can you post a
>> >> > more complete example, showing the effect that you are after? You
>> >> > mention that you
>> > want
>> >> > to hide a table. Do you want another widget to take it's place in
> the
>> >> > grid? Thanks.
>> >> >
>> >> > "Simon Rutishauser" <simon.rutishauser@gmx.ch> wrote in message
>> >> > news:pan.2003.10.04.06.56.55.788010@gmx.ch...
>> >> >> Hi,
>> >> >>
>> >> >> I checked it out. It works.
>> >> >>
>> >> >> I'd never come up with the idea of using moveBelow()/moveAbove()
>> >> >> for
>> > the
>> >> >> needed purpose. The apidoc seems to be quite wrong - or at least
>> >> >> it sounds to me as if I was ordering the controls' position in
>> >> >> z-axis direction...
>> >> >>
>> >> >>
>> >> >> import org.eclipse.swt.*;
>> >> >> import org.eclipse.swt.events.*;
>> >> >> import org.eclipse.swt.widgets.*;
>> >> >> import org.eclipse.swt.layout.*;
>> >> >>
>> >> >> public class Sample {
>> >> >> private Display display;
>> >> >> private Shell shell;
>> >> >>
>> >> >> private Shell invisibleShell;
>> >> >>
>> >> >> private Button b;
>> >> >> private Button b1, b2;
>> >> >>
>> >> >> Sample() {
>> >> >> display = new Display();
>> >> >> shell = new Shell(display, SWT.DIALOG_TRIM);
>> >> >>
>> >> >> invisibleShell = new Shell(display, SWT.NULL);
>> >> >>
>> >> >> GridLayout gl = new GridLayout();
>> >> >> shell.setLayout(gl);
>> >> >>
>> >> >> b1 = new Button(shell, SWT.NULL);
>> >> >> b1.setText("First; hide");
>> >> >> b1.addSelectionListener(new SelectionAdapter() { public void
>> >> >> widgetSelected(SelectionEvent e) { b.setParent(invisibleShell);
>> >> >> shell.pack(true);
>> >> >> }
>> >> >> }
>> >> >> );
>> >> >>
>> >> >>
>> >> >> b = new Button(shell, SWT.NULL);
>> >> >> b.setText("Middle");
>> >> >>
>> >> >> b2 = new Button(shell, SWT.NULL);
>> >> >> b2.setText("Last; show");
>> >> >> b2.addSelectionListener(new SelectionAdapter() { public void
>> >> >> widgetSelected(SelectionEvent e) { b.setParent(shell);
>> >> >> b.moveBelow(b1);
>> >> >> shell.pack(true);
>> >> >> }
>> >> >> }
>> >> >> );
>> >> >>
>> >> >> shell.pack();
>> >> >>
>> >> >> shell.open();
>> >> >>
>> >> >> while(!shell.isDisposed())
>> >> >> display.readAndDispatch();
>> >> >> }
>> >> >> }
>> >> >> public static void main(String[] args) { new Sample();
>> >> >> }
>> >> >> }
>> >> >> [/snipp]
>> >> >>
>> >> >> Peschmä
>> >> >>
>> >> >> Am Fri, 03 Oct 2003 22:35:01 +0200 schrieb Simon Rutishauser:
>> >> >>
>> >> >> > Thanks
>> >> >> >
>> >> >> > I've been doing such games for a while. (In my case I used a
>> >> >> > FormLayout and changed the FormAttachments every time
>> >> >> > :D, but here it grew too complicated)
>> >> >> >
>> >> >> > Sounds like an ugly workaround. But I can live with that.
>> >> >> >
>> >> >> > Thanks a lot
>> >> >> >
>> >> >> > Peschmä
>> >> >> >
>> >> >> > Am Fri, 03 Oct 2003 13:34:11 -0400 schrieb Emir Alikadic:
>> >> >> >
>> >> >> >> -----BEGIN PGP SIGNED MESSAGE-----
>> >> >> >> Hash: SHA1
>> >> >> >>
>> >> >> >> On 03/10/2003 12:44, Simon Rutishauser wrote:
>> >> >> >> | Yes, it _should_ definitely be setVisible().
>> >> >> >> |
>> >> >> >> | But in my case a
>> >> >> >> | table.setVisible(false); shell.pack(true); causes the space
>> >> >> >> | where the table was to be grayed (like a composite with
>> >> >> >> | nothin in it) instead
>> >> > of
>> >> >> >> | being used for other controls.
>> >> >> >>
>> >> >> >> I've had a similar problem where I had to show or hide a
> Composite
>> >> >> >> and
>> >> > I
>> >> >> >> used a Control#setParent and Control#moveBelow; I created a
>> >> >> >> dummy Shell which is never displayed which I set as a parent
>> >> >> >> when I
> want
>> > to
>> >> >> >> hide
>> >> > the
>> >> >> >> said Composite. To show it, I'd set the parent back to
>> >> >> >> original and
>> >> > use
>> >> >> >> moveBelow to put it in the right place (you should call pack()
>> >> >> >> on
>> > the
>> >> >> >> parent after that).
>> >> >> >>
>> >> >> >> There may be better ways to do it, but this one certainly works
>> >> >> >> (app in question has been in production for a while). - -- Emir
>> >> >> >> Alikadic Software Developer
>> >> >> >> CollectiveBid Systems Inc.
>> >> >> >>
>> >> >> >> "Our products just aren't engineered for security." ~ [Brian
>> >> >> >> Valentine, Senior VP Windows Division, Microsoft] -----BEGIN
>> >> >> >> PGP SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) Comment:
>> >> >> >> Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>> >> >> >>
>> >> >> >> iD8DBQE/fbMTuSy542G+Z7QRAhoxAJ4iDVOJFlUL1xIc9G8Nrs2Q0k3DCwCf dxFU
>> >> >> >> HTwMRndyYlLe9NoDvS03+no=
>> >> >> >> =GFzL
>> >> >> >> -----END PGP SIGNATURE-----
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>>
|
|
|
Goto Forum:
Current Time: Fri Sep 26 02:42:27 EDT 2025
Powered by FUDForum. Page generated in 0.04064 seconds
|