Combo Needs To Change To a Label [message #423790] |
Sun, 22 February 2004 15:18  |
Eclipse User |
|
|
|
Hi!
I have a grid layout.
One of the cells has a Combo.
In response to another control's (say a Button press) event I need to
change the combo control into a Label control.
Any idea how?
I guess one can try having two controls( Combo and Labal) in same location
(smehow)and hiding and showing either.
Let me know if you have the solution?
Thanks.
Raster
|
|
|
|
|
|
|
|
|
|
Re: Combo Needs To Change To a Label [message #426047 is a reply to message #423790] |
Mon, 01 March 2004 14:42  |
Eclipse User |
|
|
|
Originally posted by: micasim.gmx.de
On Sun, 22 Feb 2004 20:18:27 +0000 (UTC), Raster <crscca@bol.net.in> wrote:
> Hi!
> I have a grid layout.
> One of the cells has a Combo.
> In response to another control's (say a Button press) event I need to
> change the combo control into a Label control.
> Any idea how?
> I guess one can try having two controls( Combo and Labal) in same
> location
> (smehow)and hiding and showing either.
> Let me know if you have the solution?
> Thanks.
> Raster
>
Hi Raster,
Guess org.eclipse.swt.custom.StackLayout
is what will do the job.
Just putting the two controls in the same location doesn't work. Instead
you put a composite with an associated StackLayout where you want to put
the two widgets. Then you put the two widgets onto the Composite and
switch between them with StackLayout.setTopControl like in the example
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
final Composite parent = new Composite(shell, SWT.NONE);
parent.setLayoutData(new GridData(GridData.FILL_BOTH));
final StackLayout layout = new StackLayout();
parent.setLayout(layout);
final Button[] bArray = new Button[10];
for (int i = 0; i < 10; i++) {
bArray[i] = new Button(parent, SWT.PUSH);
bArray[i].setText("Button "+i);
}
layout.topControl = bArray[0];
Button b = new Button(shell, SWT.PUSH);
b.setText("Show Next Button");
final int[] index = new int[1];
b.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event e) {
index[0] = (index[0] + 1) % 10;
layout.topControl = bArray[index[0]];
parent.layout();
}
});
shell.open();
while (shell != null && !shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
Regards, michael
|
|
|
Powered by
FUDForum. Page generated in 0.05922 seconds