[ Information Environments Equipment Listing and Support ]


Smartboard Setup and Code Samples

Connecting the Smartboard to your PC

You will need to get a cable set from Di. There are 2 different types of cable sets, one that plugs directly into a USB port and the others that connect to the serial and keyboard ports. If you have one of the latter:
  • Connect the keyboard adapter to your keyboard port
  • Connect your keyboard to the adapter.
  • Plug the power plug of the keyboard adaptor into the socket on the serial connector.
  • Plug the power socket end of the serial connector into the serial port on your machine.
  • Connect the other end to the Smartboard.
If everything is connected properly the light next to the connector on the Smartboard will light up green.





Setting up to code

You will need the Smartboard java API. Once you have installed this, copy the RegistrationUtils.dll file - found in SMARTBoardSDK/Java/lib directory to the C:/j2sdk1.4.1_02/jre/bin directory. If the version of java you have installed does not have a jre directory, copy the .dll into the bin directory.

Code Samples

The sample that can be found in the SMARTBoard/Java/samples/scribble directory gives you an example of creating an application that will interface with the Smartboard. It is fairly basic, only allowing you to draw onto the screen. Listed below are 2 examples of interacting with the Smartboard, the CirclePanel and LineDrawPanel files mentioned can be found in the SmartboardSamples.zip. Also in the .zip file is a SmartboardAPITester class that allows you to test events on the Smartboard.

Running the Board in Projected Mode

This means that you have the computer screen projected onto the Smartboard which allows you to interact with programs on your computer. The following piece of code opens a window that allows you to move a circle using the Smartboard tools. As written in the comments of the code you can substitute the CirclePanel for a LineDrawPanel which allows you to draw in the frame.
import com.smarttech.board.sbsdk.*;
import javax.swing.*;

/**
 * A demo for how to register a listener with the smartboard so that you can
 * be notified when the board is touched.
 *
 * This demo is for when the board is in projected mode.
 *
 * Right now the demo uses the CirclePanel to react to board movement. 
 * This is a really simple panel that just allows you to move a circle.
 * You might want to try changing it so it uses the LineDrawJPanel instead for
 * drawing. To do this, change the line:
 *    
 *    CirclePanel panel = new CirclePanel();
 *
 * to 
 *
 *    LineDrawJPanel panel = new LineDrawJPanel();
 *
 * Instead of a "moveCircle" method, the LineDrawJPanel has a "draw" method 
 * for drawing. So, also change the line
 *
 *    panel.moveCircle(x, y);
 *
 * to 
 *    
 *    panel.draw(x, y);
 *
 *
 * @author Bea Lam
 * @version 0.5 Feb 2003
 */

public class ProjectedModeFrame extends JFrame {
   
      
   /*
    * Runs the capture-touch demo for non-projected mode
    */
   public static void main(String[] args) {
      
      ProjectedModeFrame frame = new ProjectedModeFrame();
      
      // show the frame, then register it with the smartboard. You must call
      // show() on the frame before you can register it with the 
      // smartboard.attach method.
      frame.show();
      frame.registerSmartboard(); 
   }
   //--------------
   
   /** the panel that holds the drawing */
   CirclePanel panel = new CirclePanel();
   
   /**
    * sets up this frame 
    */
   public ProjectedModeFrame() {
      
      // add the drawing panel to this frame      
      getContentPane().add(panel);
      
      // set this frame's location and size
      setBounds(100, 100, 700, 700);
   }      

   /**
    * Registers this frame so that it is able to be notified by the smartboard
    * when something happens on the board (e.g. when it's touched)
    */
   public void registerSmartboard() {
      // connect to the smartboard, and attach this frame to it
      SBSDK smartboard = new SBSDK();
      smartboard.attach(this, false);
      
      // make a board listener to react when someone draws on the board
      SBSDKListener boardListener = new SBSDKAdapter() {
         
         public void onXYDown(int x, int y, int z, int pointerID) {
            System.out.println("Someone touched the board");
         }
         public void onXYUp(int x, int y, int z, int pointerID) {
            System.out.println("Someone has released pressure on the board");
         }
         public void onXYMove(int x, int y, int z, int pointerID) {
            // tell the panel to move the circle to the new point
            panel.moveCircle(x, y);
         }            
      };
           
      // register the panel and board listener so that the listener
      // will be notified when something happens on the board, and also whenever 
      // the smartboard is touched inside the panel
      smartboard.registerComponent(panel, boardListener);      
      
   }   
   
}

Running the Board in Non-Projected Mode

This means that the SmartBoard is not projected upon and operates as if a whiteboard. As written in the comments of the code you can substitute the CirclePanel for a LineDrawPanel which allows you to draw in the frame.
import com.smarttech.board.sbsdk.*;
import javax.swing.*;

/**
 * A demo for how to register a listener with the smartboard so that you can
 * be notified when the board is touched.
 *
 * This demo is for when the board is in non-projected mode.
 *
 * Right now the demo uses the CirclePanel to react to board movement. 
 * This is a really simple panel that just allows you to move a circle.
 * You might want to try changing it so it uses the LineDrawJPanel instead for
 * drawing. To do this, change the line:
 *    
 *    CirclePanel panel = new CirclePanel();
 *
 * to 
 *
 *    LineDrawJPanel panel = new LineDrawJPanel();
 *
 * Instead of a "moveCircle" method, the LineDrawJPanel has a "draw" method 
 * for drawing. So, also change the line
 *
 *    panel.moveCircle(x, y);
 *
 * to 
 *    
 *    panel.draw(x, y);
 *
 *
 * @author Bea Lam
 * @version 0.5 Feb 2003
 */

public class NonProjectedModeFrame extends JFrame {
      
   /*
    * Runs the capture-touch demo for non-projected mode
    */
   public static void main(String[] args) {
      
      NonProjectedModeFrame frame = new NonProjectedModeFrame();
      
      // show the frame, then register it with the smartboard. You must call
      // show() on the frame before you can register it with the 
      // smartboard.attach method.
      frame.show();
      frame.registerSmartboard(); 
   }
   //--------------
      
   /** the panel that holds the drawing */
   CirclePanel panel = new CirclePanel();
      
   /**
    * sets up this frame 
    */
   public NonProjectedModeFrame() {
      
      // add the drawing panel to this frame     
      getContentPane().add(panel);
      
      // set this frame's location and size
      setBounds(100, 100, 700, 700);      
   }
   
   /**
    * Registers this frame so that it is able to be notified by the smartboard
    * when something happens on the board (e.g. when it's touched)
    */
   public void registerSmartboard() {

      // connect to the smartboard, and attach this frame to it
      SBSDK smartboard = new SBSDK();
      smartboard.attach(this, false);
      
      // make a board listener to react when someone draws on the board
      SBSDKListener boardListener = new SBSDKAdapter() {
      
         public void onXYNonProjectedDown(int x, int y, int z, int pointerID) {
            System.out.println("Someone touched the board");
         }
         public void onXYNonProjectedUp(int x, int y, int z, int pointerID) {
            System.out.println("Someone has released pressure on the board");
         }               
         
         public void onXYNonProjectedMove(int x, int y, int z, int pointerID) {
            
            // scale the point's X-Y position to fit in the panel
            x = x * panel.getWidth() / SBSDK.SBSDK_NON_PROJECTED_RANGE;
            y = y * panel.getHeight() / SBSDK.SBSDK_NON_PROJECTED_RANGE;
            
            // tell the panel to move the circle to the new point
            panel.moveCircle(x, y);
         }            
      };
           
      // register the panel and board listener so that the listener
      // will be notified when something happens on the board
      smartboard.registerComponent(panel, boardListener);   
      
   }
   
}
© Lorna Macdonald 2003
Feel free to contact me at s4008068@student.uq.edu.au