// on Linux or Win install SwingOSC first
// see SwingOSC/SuperCollider/readme.html

// assign the SwingOSC GUI server to g (as s is assigned to Server.local)
g = SwingOSC.default;
g.boot;

// test:
JSCWindow.viewPalette;

GUI.cocoa;
GUI.swing;

( // to see a server window via the GUI class (i.e. cross-platform), execute this:
if( s.window.notNil, { s.window.close });
s.makeWindow;
)

//  whith SwingOSC Server scope works also on the local server!
s.scope;

// also does loadDialog ...
b = Buffer.loadDialog

// .. and plot
b.plot

Env.perc(0.1, 1.0).plot

Array.rand(30, 0.0, 1.0).plot

{ SinOsc.ar(100, 0, EnvGen.kr(Env.perc(0.1, 1.0))) }.plot(1.1)

// working with windows and GUI elements

(
var w, bt, sl1, sl2, sl3;
var synth;

/*
SynthDef("yourown", { arg freq=300, rate=4, amp=0.3;

	
	}).store;
*/	

w = GUI.window.new( "testwindow", Rect( 200, 400, 340, 360 ));

GUI.staticText.new(w, Rect(20, 20, 200, 20)).string_("pitch");

sl1 = GUI.slider.new(w, Rect(10, 40, 200, 20));
sl1.action = { arg view;
	synth.set(\freq, (view.value * 36 + 48).midicps);
	};

GUI.staticText.new(w, Rect(20, 70, 200, 20)).string_("rate");

sl2 = GUI.slider.new(w, Rect(10, 90, 200, 20));
sl2.action = { arg view;
	synth.set(\rate, view.value * 30 + 0.1);
	};

GUI.staticText.new(w, Rect(20, 120, 200, 20)).string_("amp");

sl3 = GUI.slider.new(w, Rect(10, 140, 200, 20));
sl3.action = { arg view;
	synth.set(\amp, (view.value * 60 - 60).dbamp);
	};

bt = GUI.button.new(w, Rect(80, 200, 100, 30));
bt.font = GUI.font.new("Arial", 22);
bt.states = [["mute", Color.red(0.7), Color.black], ["muted", Color.black, Color.red]];
bt.action = { arg view;
	synth.run( [true, false].at(view.value) );
	};

w.front;
w.onClose = { synth.release };

//synth = Synth("yourown");
synth = Synth("default");

)