## SwingOSC – Java-based GUI classes

last mod: 13-Jan-08 sciss

# JSCPlugView, JSCPlugContainerView

This class allows you to add any `javax.swing.JComponent` or `javax.swing.JPanel` subclass to an JSCWindow or one of its containers. See also: JSCView, JavaObject

## Instantiation

    	JSCPlugView.new( <(JSCView) parent>, <(Rect) bounds>, <(JavaObject) javaObject> )

The SwingOSC server is taken from `javaObject`. Any unknown message call is redirected to the server, similar to what JavaObject. Note: There is no getter methods implementation right now.

Example:

    (
        var win, progBar, tab, flow, lb1, lb2, check, rout;

        win = JSCWindow( "Schoko", Rect.new( 128, 64, 400, 470 ));
        flow = FlowLayout( win.view.bounds );
        win.view.decorator = flow;

        // we can create gadgets ...
        progBar = JSCPlugView( win, Rect( 0, 0, 390, 24 ), JavaObject( 'javax.swing.JProgressBar' ));

        // ... and containers
        tab = JSCPlugContainerView( win, Rect( 0, 0, 400, 400 ), JavaObject( 'javax.swing.JTabbedPane' ));

        // ... and gadgets inside containers
        lb1 = JSCPlugView( tab, Rect( 10, 20, 360, 360 ), JavaObject( 'javax.swing.JLabel' ));

        // we can talk to these through their java methods
        lb1.setIcon( JavaObject( 'javax.swing.ImageIcon', nil, '/Library/Desktop Pictures/Ripples Moss.jpg' ));

        lb2 = JSCPlugView( tab, Rect( 10, 20, 360, 360 ), JavaObject( 'javax.swing.JLabel' ));
        lb2.setIcon( JavaObject( 'javax.swing.ImageIcon', nil, '/Library/Desktop Pictures/Nature/Faux Fur.jpg' ));

        JSCPlugView( tab, Rect( 10, 20, 360, 360 ), JavaObject( 'javax.swing.JColorChooser' ));

        // ... and containers
        tab.setTitleAt( 0, "Image 1" );
        tab.setTitleAt( 1, "Image 2" );
        tab.setTitleAt( 2, "Color" );

        // we can mix with regular gadget types
        JSCButton( win, Rect( 0, 0, 80, 24 ))
            .states_([[ "Aha" ]]);

        rout = Routine({
            var value;
            inf.do({ arg i;
                value = i % 101;
                progBar.setValue( value );
                if( value == 100, 2, 0.1 ).wait;
            });
        });

        win.onClose = {
            rout.stop;
            // should we dispose the images? not sure at the moment
        };

        win.front;

        rout.play;
    )