Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Isadora: Communication & Sensors:
JavaOSC Example

 

 


Mark Coniglio
TroikaTronix / Moderator

Aug 25, 2008, 11:02 PM

Post #1 of 1 (228 views)
Shortcut
JavaOSC Example Can't Post

I recently helped someone out getting JavaOSC to communicate with Isadora. I modified the paint() function of this simple "hello world" applet to send the integer 5 to Isadora.

The javaOSC libraries can be downloaded at http://www.illposed.com/software/javaosc.html

Best Wishes,
Mark


Code
 
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import com.illposed.osc.*;
import java.net.*;
import java.io.*;

public class JavaOSCTest extends JApplet {

static final String message = "Hello World!";
private Font font = new Font("serif", Font.ITALIC + Font.BOLD, 36);

public void init() {
// set the default look and feel
String laf = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(laf);
} catch (UnsupportedLookAndFeelException exc) {
System.err.println ("Warning: UnsupportedLookAndFeel: " + laf);
} catch (Exception exc) {
System.err.println ("Error loading " + laf + ": " + exc);
}
getContentPane().setLayout (null);
}

public void paint (Graphics g) {

try {
InetAddress addr = InetAddress.getLocalHost();
OSCPortOut sender = new OSCPortOut(addr, 1234);
OSCMessage msg = new OSCMessage("/isadora/1");
msg.addArgument(new Integer(5));
sender.send(msg);
} catch (UnknownHostException e) {
} catch (IOException e) {
}

super.paint(g);
g.setColor(Color.blue);
g.setFont(font);
g.drawString(message, 40, 80);
}
}


- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Mark Coniglio / TroikaTronix
Creator of Isadora

 
 
 


Search for (options) copyright © TroikaTronix 2007