Fourth in a series of gradually more complex and varied GUI examples.
An Even More Complex Example...

(
SynthDef("variablesine", { arg freq=80, freq2=1, amp=1, pan=0.5;  // almost the same as before....
	var osc;										          // this time we have added an arg
	osc = SinOsc.ar(freq*freq2);                                 // to control the pan. A value of 
	Out.ar(0, [osc*amp*(1-pan), osc*amp*pan]);		          // 1 will pan hard right, 0 hard left
}).writeDefFile;
)

(
SynthDef("modulator", { arg freq=80, amp=1;
	var osc;
	osc = SinOsc.ar(freq);
	ReplaceOut.kr(10, osc*amp);
}).writeDefFile;
)

(
var w, b1, b2, b3, sl1, sl2, sl3, sl4, sl5, num1, num2, num3, num4;    //lots of variables!
var str1, str2, str3, str4, str5, str6, str7, str8, str9, s;

s = Server.local;			// instance of a local server

// Create window - 350 x 500 pixels
w = SCWindow("Simple FM Controller", Rect(100, 800, 350, 500));
w.view.background = Color.gray;	// the window background will be gray
w.front;						// Bring the window to the front

// Create our 3 buttons
b1 = SCButton(w, Rect(5, 5, 110, 25));	// The first button starts and stops the server
b1.states = [
		["Start Server"],
		["Stop Server"],
			];
b1.action = { arg view;
		if (b1.value == 1, {
				s.boot;
		},{
				s.quit;
		});
};

b2 = SCButton(w, Rect(120, 5, 110, 25));	// This button sends both our SynthDefs
b2.states = [
		["Load SynthDefs"]
			];
b2.action = { arg view;
	s.sendSynthDef("variablesine");
	s.sendSynthDef("modulator");
};

b3 = SCButton(w, Rect(235, 5, 110, 25));	// This one starts and stops the synths
b3.states = [
		["Play"],
		["Stop"],
			];
b3.action = { arg view;
		if (b3.value == 1, {
				s.sendMsg("/s_new", "variablesine", 1000, 1, 0, "freq", 80, "freq2", 1);
				s.sendMsg("/s_new", "modulator", 1001, 0, 0, "freq", 80);
				s.sendMsg("n_map", 1000, \freq2, 10);
				sl2.value = 1;	// These two commands set sliders 2 and 4 to values of
				sl4.value = 1/20;	// 1 and 1/20 whenever you start the synth
		},{
				s.sendMsg("/n_free", 1000);
				s.sendMsg("/n_free", 1001);
		});
};

// Create our sliders
sl1 = SCSlider(w, Rect(25, 100, 50, 300));
sl1.action = {
		var val;
		val = ((800*sl1.value)+80);
		s.sendMsg("/n_set", 1000, "freq", val);
		num1.value = val;		// This will set the value of number box 1 = value of slider 1
};

sl2 = SCSlider(w, Rect(107, 100, 50, 300));
sl2.action = {
		var val;
		val = sl2.value;
		s.sendMsg("/n_set", 1000, "amp", val);
		num2.value = val;		// This will set the value of number box 2 = value of slider 2
};

sl3 = SCSlider(w, Rect(191, 100, 50, 300));
sl3.action = {
		var val;
		val = ((1000*sl3.value)+1);
		s.sendMsg("/n_set", 1001, "freq", val);
		num3.value = val;		// This will set the value of number box 3 = value of slider 3
};

sl4 = SCSlider(w, Rect(274, 100, 50, 300));
sl4.action = {
		var val;
		val = (20*sl4.value);
		s.sendMsg("/n_set", 1001, "amp", val);
		num4.value = val;		// I'm sure you can guess by now what this does!
};

sl5 = SCSlider(w, Rect(75, 40, 200, 30));			// This slider will control the pan
sl5.value = 0.5;								// The default position is set to 0.5 (halfway)
sl5.action = {
		var val;
		val = sl5.value;
		s.sendMsg("/n_set", 1000, "pan", val);	// The value of the slider position is sent to the
};											// pan argument of node 1000 (our variablesine synth)

// Create our text strings
str1 = SCStaticText(w, Rect(23, 70, 133, 30));		// All of our text strings are assigned a position,
str1.string = "|-------Variablesine-------|";		// content and Font type. You can send colour
str1.font = Font("Futura-Medium", 14);			// (or color!) information as well.

str2 = SCStaticText(w, Rect(189, 70, 133, 30));
str2.string = "|---------Modulator---------|";
str2.font = Font("Futura-Medium", 14);

str3 = SCStaticText(w, Rect(23, 400, 55, 25));
str3.string = "Freq(Hz)";
str3.font = Font("Futura-Medium", 14);

str4 = SCStaticText(w, Rect(112, 400, 55, 25));
str4.string = "Amp.";
str4.font = Font("Futura-Medium", 14);

str5 = SCStaticText(w, Rect(189, 400, 55, 25));
str5.string = "Freq(Hz)";
str5.font = Font("Futura-Medium", 14);

str6 = SCStaticText(w, Rect(280, 400, 55, 25));
str6.string = "Amp.";
str6.font = Font("Futura-Medium", 14);

str7 = SCStaticText(w, Rect(165, 42, 50, 25));
str7.string = "Pan";
str7.font = Font("Futura-Medium", 14);

str8 = SCStaticText(w, Rect(62, 42, 10, 25));
str8.string = "L";
str8.font = Font("Futura-Medium", 14);

str9 = SCStaticText(w, Rect(279, 42, 10, 25));
str9.string = "R";
str9.font = Font("Futura-Medium", 14);

//create our number boxes
num1 = SCNumberBox(w, Rect(25, 430, 50, 25));		// Finally, we create our number boxes.
num2 = SCNumberBox(w, Rect(107, 430, 50, 25));		// Each one is assigned a size and position.
num3 = SCNumberBox(w, Rect(191, 430, 50, 25));		// You can assign a default value by using
num4 = SCNumberBox(w, Rect(274, 430, 50, 25)); 	// variablename.value = number eg num1.value = 80; 

)