hhheng 0 Newbie Poster

Newbie questions. I laid out the controls in shell by GridLayout(2, false). And when user click a checkbox, I wantto to hide one or several lines. I tried to set the exclude to true, and set the control in that line GridData(0, 0) to hide those lines. However there were many problems. Code as below:

BTW, are there any other ways to hide and show controls while using SWT?

Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setText("Just for testing");
		GridLayout layout = new GridLayout(2, false);
		shell.setLayout(layout);
		
		Label label = new Label(shell, SWT.None);
		label.setText("User:");
		GridData data1 = new GridData(80, SWT.DEFAULT);
		label.setLayoutData(data1);
		Text text = new Text(shell, SWT.SINGLE);
		GridData data2 = new GridData(150, SWT.DEFAULT);
		data2.horizontalAlignment = GridData.BEGINNING;
		text.setLayoutData(data2);
		
		new Label(shell, SWT.None).setText("");
		Button b = new Button(shell, SWT.CHECK);
		b.setText("Add more strings???????????");
		
		final Label dlabel = new Label(shell, SWT.None);    //Trying to hide this line
		dlabel.setText("Description:");
		final Text dtext = new Text(shell, SWT.MULTI);
		final GridData hide = new GridData(0, 0);
		hide.exclude = true;
		dtext.setLayoutData(hide);
		dlabel.setLayoutData(hide);
		
		label = new Label(shell, SWT.None);
		label.setText("User:");
		data1 = new GridData(80, SWT.DEFAULT);
		label.setLayoutData(data1);
		text = new Text(shell, SWT.SINGLE);
		data2 = new GridData(150, SWT.DEFAULT);
		data2.horizontalAlignment = GridData.BEGINNING;
		text.setLayoutData(data2);	
		
		final GridData ldata = new GridData(80, SWT.DEFAULT);
		final GridData rdata = new GridData(150, 50);
		
		b.addListener(SWT.Selection, new Listener(){
			public void handleEvent(Event e){
				if(dtext.getLayoutData() == hide){
					dlabel.setLayoutData(ldata);
					dtext.setLayoutData(rdata);
					dlabel.setVisible(true);
					dtext.setVisible(true);
				}else{
					dlabel.setLayoutData(hide);
					dtext.setLayoutData(hide);
					dlabel.setVisible(false);
					dtext.setVisible(false);
				}
				
				shell.layout();
			}
		});
		
		shell.setSize(300, 400);
		shell.open();
		while(!shell.isDisposed()){
			if(display.readAndDispatch()) display.sleep();
		}

Help please, thanks a lot.