RedJWindow wrapper for JSCWindow


Inherits from: JSCWindow


adding some functionallity to the standard window class.

requires RedVector and SwingOSC

this class can also be used with osx-swing.  copy the class file RedJWindow.sc into the osx folder.


see also: RedWindow, JSCWindow


instance methods:

draw(func)

alias for drawFunc_

play(fps= 40)

starts an internal thread on the AppClock updating at rate fps

stop

stop internal thread

resize([width, height])

change window size while keeping x and y position.  the argument can also be a RedVector

background_(color)

set window background.  alias for view.background_

isOpen

boolean


instance variables:

<>mouse

returns a RedVector for mouse x and y position.  click&drag in window to set position.

<isPlaying

if the window is updating

<userView

access to the embedded view


animate_(bool)

start automatic refresh.  default at 60fps.  (although swingosc seems capped at 50)

frame

current frame.

frameRate

current average framerate.


//--

GUI.swing;

w= RedJWindow.new.front;

w.resize(RedVector2D[200, 200])

w.background= Color.red


w.draw{Pen.fillColor= Color.black; Pen.fillOval(Rect.aboutPoint(175.rand@175.rand, 50, 50))}

w.play //start drawing

w.stop


( //mouse control

w.draw{

var radius= 100.rand;

Pen.fillColor= Color.blue(0.5, radius/100);

Pen.fillOval(Rect.aboutRedVector2D(w.mouse, radius))

}

)

w.play(25) //25fps

w.mouse

w.isPlaying

w.isOpen

w.stop

w.animate= true; //60fps

w.frame

w.frameRate

w.close