Change the Next class as follows:
public class Next extends Composite {
private Text txtYouAreIn;
public Next(Composite parent, int style) {
super(parent, style);
Button btnYay = new Button(parent, SWT.NONE);
btnYay.setBounds(43, 58, 75, 25);
btnYay.setText("Yay");
txtYouAreIn = new Text(parent, SWT.BORDER);
txtYouAreIn.setText("You are in a new");
txtYouAreIn.setBounds(173, 113, 115, 21);
}
}
Add the below line in btnNewButton listener i.e in widgetSelected
method
composite.setVisible(!composite.isVisible());