Drawing surface

I have a small program, and right now it's just the interface. This one is suppose to plot polynomials, but my drawing surface isn't showing up. I'll post the code for the drawing surface, which is an external class, if needed, I will post the whole thing.
import java.awt.image.*;
import java.awt.*;
import javax.swing.*;
public class ImagePlotter extends JPanel
     BufferedImage cartisianImage;
     Graphics2D g2d;
     public ImagePlotter()
     public void paintComponent(Graphics g)
          g2d = (Graphics2D)g;
          int width = 300;
          int height = 300;
          cartisianImage = (BufferedImage)(this.createImage(width,height));
          Graphics2D gc = cartisianImage.createGraphics();
          g2d.drawImage(cartisianImage,null,0,0);
     public void drawPolynomialLine(int[] xPoints, int[] yPoints, int count)
          g2d.drawPolyline(xPoints,yPoints, count);
          repaintComponent();
     public void repaintComponent()
          repaint();
}In the "driver" class, I do this:
ImagePlotter ip = new ImagePlotter();
//then i add it to the container
pane.add(ip);

Why use a buffered image? You can make that work, but it's generally easier and just as effective to do the drawing in your paintComponent() method.
Try adding this to your ImagePlotter() constructor:
setPreferredSize( new Dimension(300, 300) );Then your enclosing JFrame can just pack() and it should come out all right.
In your paintComponent() method, discard the image and just call your draw method. But try something simple, to make sure the driver and drivee are working together. Something like this in paintComponent():
g.setColor( Color.BLUE );
g.fillRect( 10, 10, 100, 100 );When that works, get on to debugging the real draw code. And since you'll be calling the draw code from paintComponent(), discard repaintComponent() and the call to it in drawPolynumialLine().
Good luck!

Similar Messages

  • Simple drawing surface - Edge

    Hi I wants to do a simple drawing surface that you can easily pop into your pages, similar to the basic windows paint program.
    I find A jQuery paint plugin (http://wpaint.websanova.com) but i can't use it. Please help me or prepare me dome file or something like that.
    THX
    Daniel Poland

    hey kglad....
    i got something like this so far.....
    still a bit stuck on drawing a recatangle that can be
    scalable by the user and can be draged around the screen...
    will i have to keep on creating movie clips for every
    rectangle the user wants to create....
    im trying to buld a simple room map app, where the user can
    draw a plan of a house.. each room will be a rectangle.
    onMouseDown = function () {
    this.createEmptyMovieClip("rectang", 1);
    rectang.lineStyle(1, 0x000000, 100);
    rectang.moveTo(_xmouse, _ymouse);
    onMouseMove = function () {
    rectang.clear();
    //draw rect here...
    onMouseUp = function () {
    };

  • JNI assert fails getting the drawing surface

    The following code fails because JAWT_DrawingSurface *ds is null after the assignment ds = awt.GetDrawingSurface(env, canvas);
    I don't understand why this is null and am struggling to debug the code with print statements. As I don't know how to debug JNI through xcode. think it's probably something simple I am missing as I downloaded a working example that uses the same setup code.
    Thanks for all your help
    David
       JAWT awt;
        JAWT_DrawingSurface* ds = NULL;
        JAWT_DrawingSurfaceInfo* dsi = NULL;
        JAWT_MacOSXDrawingSurfaceInfo* dsi_mac = NULL;
        jboolean result = JNI_FALSE;
        jint lock = 0;
        // get the AWT
        awt.version = JAWT_VERSION_1_4;
        result = JAWT_GetAWT(env, &awt);
        if (env->ExceptionOccurred()) {
            env->ExceptionDescribe();
        assert(result != JNI_FALSE);
        // Get the drawing surface.  This can be safely cached.
        // Anything below the DS (DSI, contexts, etc)
        // can possibly change/go away and should not be cached.
        ds = awt.GetDrawingSurface(env, canvas);
        if (env->ExceptionOccurred()) {
            env->ExceptionDescribe();
         if(!ds)
              std::cout << "ds is null" << std::endl;
              std::cout << "env address is : " << env << std::endl;
              std::cout << "canvas address is : " << &canvas << std::endl;
              return;
        assert(ds != NULL);
        // Lock the drawing surface
        // You must lock EACH TIME before drawing
        lock = ds->Lock(ds);
        if (env->ExceptionOccurred()) {
            env->ExceptionDescribe();
        assert((lock & JAWT_LOCK_ERROR) == 0);
        // Get the drawing surface info
        dsi = ds->GetDrawingSurfaceInfo(ds);
        // Check DrawingSurfaceInfo.  This can be NULL on Mac OS X
        // if the windowing system is not ready
        if (dsi != NULL) {
            // Get the platform-specific drawing info
            // We will use this to get at Cocoa and CoreGraphics
            // See <JavaVM/jawt_md.h>
            dsi_mac = (JAWT_MacOSXDrawingSurfaceInfo*)dsi->platformInfo;
            if (env->ExceptionOccurred()) {
                env->ExceptionDescribe();
            // Get the corresponding peer from the caller canvas
            NSView *view = dsi_mac->cocoaViewRef;
            // Get the CoreGraphics context from the parent window.
            // DO NOT CACHE NSGraphicsContexts -- they may go away.
            NSWindow *window = [view window];
            NSGraphicsContext *ctxt = [NSGraphicsContext graphicsContextWithWindow:window];
            CGContextRef cg = static_cast<CGContextRef>([ctxt graphicsPort]);
            // Match Java's ctm
            NSRect windowRect = [window frame];
            CGContextConcatCTM(cg, CGAffineTransformMake(1, 0, 0, -1, dsi->bounds.x, windowRect.size.height-dsi->bounds.y));
            // Draw a pattern using CoreGraphics
            CGContextSetRGBFillColor(cg, 1.0f, 0.0f, 0.0f, 1.0f);
            CGContextFillRect(cg, CGRectMake(15, 15, dsi->bounds.width-30, dsi->bounds.height-30));
            // Free the DrawingSurfaceInfo
            ds->FreeDrawingSurfaceInfo(dsi);
            if (env->ExceptionOccurred()){
                env->ExceptionDescribe();
            }

    I've got past that problem, which was due to the declaration of the jni functions not being in a canvas class. However, I am now getting a segmentation fault when assigning the lock.
    lock = ds->Lock(ds);

  • Image drawing in cocoa

    Hi Friends,
    I need a make a java canvas in which i have to paint thumbnail images by native cocoa code.
    I had got drawing surface(ds) and drawing surface interface(dsi).Also i am able to read the thumbnail images but donot know how to paint images in canvas.
    Please suggest and if possible give some example or code sample.
    Thanks in advance.

    Welcome to Apple Discussions, Vinod!
    You have asked your question in a forum devoted to questions about Apple Discussions themselves. You are much more likely to get an answer in the "Developer" forum:
    http://discussions.apple.com/thread.jspa?threadID=1064635&tstart=0

  • Drawing with carbon (agl) to NSWindow

    I need to update a legacy library so that it can draw to an NSWindow with agl and Carbon. I actually have no problem drawing, the problem is that I am drawing over the window decorations and don't know how not to. Has anyone run into this problem?
    Thanks

    I don't know about AGLCLIPREGION, but I can suggest an alternate approach that I think will achieve the effect you want. First, use AGLSURFACEORDER to put the OpenGL drawing surface behind the window. Second, install a handler for the kEventClassWindow / kEventWindowGetRegion Carbon Event to make the window's opaque region empty. You may need to call ReshapeCustomWindow after installing the event handler to put the region change into effect. And use CGContextClearRect to cut a rectangular hole in the window so that your drawing surface can be seen.
    By the way, the OpenGL mailing list at lists.apple.com might be a place where your question will be seen by more experts.

  • Drawing straight lines

    Hi,
    in my programm I need to draw straight lines(I hope this is the correct translation for an infinit line). Is there a way of doing this?

    I just answered my own question.
    I checked Illustrator Preferences and under GENERAL: CONSTRAIN ANGLE, mine was set to 0.19 degrees (for reasons unknown).
    I changed it to zero and Voila! Who'd have thought this would alter the whole drawing surface?
    All I had to do was ask others in order to figure it out myself! Hope this helps anybody else having this bizarre problem.
    Vic.

  • Illustrator drawing straight lines crooked

    All straight lines in Illustrator appear crooked on my screen. This is hard to explain. I've been using AI since 1991 and have never seen this problem, which started happening out of the blue a few months ago, even though I have not changed anything on my system or setup. This problem doesn't happen in any other programs, including InDesign.
    Examples:
    Use the box tool to draw a box. The lines should be straight, but they are crooked. You know when you use the pen tool and draw a line without holding the Shift key, and the line is jagged where it isn't straight? Well, that's what my lines look like when they are supposed to be straight, like from a box.
    The lines are also crooked when I draw with the pen tool using the Shift key to constrain.
    Even the document frame is crooked. I took a screen shot of an example. Please see it at this link:
    http://www.theheadbone.com/crooked.html
    THANK YOU for any help anybody can offer!
    Victoria
    Mac OSX 10.5.6
    AI CS3. 13.02
    Using MacBook Pro with Apple Cinema Display 20"

    I just answered my own question.
    I checked Illustrator Preferences and under GENERAL: CONSTRAIN ANGLE, mine was set to 0.19 degrees (for reasons unknown).
    I changed it to zero and Voila! Who'd have thought this would alter the whole drawing surface?
    All I had to do was ask others in order to figure it out myself! Hope this helps anybody else having this bizarre problem.
    Vic.

  • Trying to create a surface  with multiple images with mouse events

    novice programmer (for a applet program)
    hi trying to create a surface i.e jpanel, canvas, that allows multiple images to be created.
    Each object is to contain a image(icon) and a name associated with that particular image. Then each image+label has a mouse event that allows the item to be dragged around the screen.
    I have tried creating own class that contains a image and string but I having problems.
    I know i can create a labels with icons but having major problems adding mouse events to allow each newly created label object to moved by the users mouse?
    if any one has any tips of how to acheive this it would be much appreciated. Thanks in advance.
    fraser.

    This should set you on the right track:- import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;
        public class DragTwoSquares extends JApplet implements MouseListener, MouseMotionListener {  
           int x1, y1;   // Coords of top-left corner of the red square.
           int x2, y2;   // Coords of top-left corner of the blue square.
           /* Some variables used during dragging */
           boolean dragging;      // Set to true when a drag is in progress.
           boolean dragRedSquare; // True if red square is being dragged, false                              //    if blue square is being dragged.                            
           int offsetX, offsetY;  // Offset of mouse-click coordinates from
                                  //   top-left corner of the square that was                           //   clicked.
           JPanel drawSurface;    // This is the panel on which the actual
                                  // drawing is done.  It is used as the
                                  // content pane of the applet.  It actually                      // belongs to an anonymous class which is
                                  // defined in place in the init() method.
            public void init() {
                 // Initialize the applet by putting the squares in a
                 // starting position and creating the drawing surface
                 // and installing it as the content pane of the applet.
              x1 = 10;  // Set up initial positions of the squares.
              y1 = 10;
              x2 = 50;
              y2 = 10;
              drawSurface = new JPanel() {
                        // This anonymous inner class defines the drawing
                        // surface for the applet.
                    public void paintComponent(Graphics g) {
                           // Draw the two squares and a black frame
                           // around the panel.
                       super.paintComponent(g);  // Fill with background color.
                       g.setColor(Color.red);
                       g.fillRect(x1, y1, 30, 30);
                       g.setColor(Color.blue);
                       g.fillRect(x2, y2, 30, 30);
                       g.setColor(Color.black);
                       g.drawRect(0,0,getSize().width-1,getSize().height-1);
              drawSurface.setBackground(Color.white);
              drawSurface.addMouseListener(this);
              drawSurface.addMouseMotionListener(this);
              setContentPane(drawSurface);
           } // end init();
           public void mousePressed(MouseEvent evt) {
                  // Respond when the user presses the mouse on the panel.
                  // Check which square the user clicked, if any, and start
                  // dragging that square.
              if (dragging)  // Exit if a drag is already in progress.
                 return;           
              int x = evt.getX();  // Location where user clicked.
              int y = evt.getY();        
              if (x >= x2 && x < x2+30 && y >= y2 && y < y2+30) {
                     // It's the blue square (which should be checked first,
                     // since it's in front of the red square.)
                 dragging = true;
                 dragRedSquare = false;
                 offsetX = x - x2;  // Distance from corner of square to (x,y).
                 offsetY = y - y2;
              else if (x >= x1 && x < x1+30 && y >= y1 && y < y1+30) {
                     // It's the red square.
                 dragging = true;
                 dragRedSquare = true;
                 offsetX = x - x1;  // Distance from corner of square to (x,y).
                 offsetY = y - y1;
           public void mouseReleased(MouseEvent evt) {
                  // Dragging stops when user releases the mouse button.
               dragging = false;
           public void mouseDragged(MouseEvent evt) {
                   // Respond when the user drags the mouse.  If a square is
                   // not being dragged, then exit. Otherwise, change the position
                   // of the square that is being dragged to match the position
                   // of the mouse.  Note that the corner of the square is placed
                   // in the same position with respect to the mouse that it had
                   // when the user started dragging it.
               if (dragging == false)
                 return;
               int x = evt.getX();
               int y = evt.getY();
               if (dragRedSquare) {  // Move the red square.
                  x1 = x - offsetX;
                  y1 = y - offsetY;
               else {   // Move the blue square.
                  x2 = x - offsetX;
                  y2 = y - offsetY;
               drawSurface.repaint();
           public void mouseMoved(MouseEvent evt) { }
           public void mouseClicked(MouseEvent evt) { }
           public void mouseEntered(MouseEvent evt) { }
           public void mouseExited(MouseEvent evt) { }  
        } // end class

  • How do I convert this Applet to launch from a JFrame instead??

       A simple program where the user can sketch curves and shapes in a
       variety of colors on a variety of background colors.  The user selects
       a drawing color form a pop-up menu at the top of the
       applet.  If the user clicks "Set Background", the background
       color is set to the current drawing color and the drawing
       area is filled with that color.  If the user clicks "Clear",
       the drawing area is just filled with the current background color.
       The user selects the shape to draw from another pop-up menu at the
       top of the applet.  The user can draw free-hand curves, straight
       lines, and one of six different types of shapes.
       The user's drawing is saved in an off-screen image, which is
       used to refresh the screen when repainting.  The picture is
       lost if the applet changes size, however.
       This file defines two classes, SimplePaint3,class, and
       class, SimplePaint3$Display.class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SimplePaint3 extends JApplet {
            // The main applet class simply sets up the applet.  Most of the
            // work is done in the Display class.
       JComboBox colorChoice, figureChoice;  // Pop-up menus, defined as instance
                                             // variables so that the Display
                                             // class can see them.
       public void init() {
          setBackground(Color.gray);
          getContentPane().setBackground(Color.gray);
          Display canvas = new Display();  // The drawing area.
          getContentPane().add(canvas,BorderLayout.CENTER);
          JPanel buttonBar = new JPanel();       // A panel to hold the buttons.
          buttonBar.setBackground(Color.gray);
          getContentPane().add(buttonBar, BorderLayout.SOUTH);
          JPanel choiceBar = new JPanel();       // A panel to hole the pop-up menus
          choiceBar.setBackground(Color.gray);
          getContentPane().add(choiceBar, BorderLayout.NORTH);
          JButton fill = new JButton("Set Background");  // The first button.
          fill.addActionListener(canvas);
          buttonBar.add(fill);
          JButton clear = new JButton("Clear");   // The second button.
          clear.addActionListener(canvas);
          buttonBar.add(clear);
          colorChoice = new JComboBox();  // The pop-up menu of colors.
          colorChoice.addItem("Black");
          colorChoice.addItem("Red");
          colorChoice.addItem("Green");
          colorChoice.addItem("Blue");
          colorChoice.addItem("Cyan");
          colorChoice.addItem("Magenta");
          colorChoice.addItem("Yellow");
          colorChoice.addItem("White");
          colorChoice.setBackground(Color.white);
          choiceBar.add(colorChoice);
          figureChoice = new JComboBox();  // The pop-up menu of shapes.
          figureChoice.addItem("Curve");
          figureChoice.addItem("Straight Line");
          figureChoice.addItem("Rectangle");
          figureChoice.addItem("Oval");
          figureChoice.addItem("RoundRect");
          figureChoice.addItem("Filled Rectangle");
          figureChoice.addItem("Filled Oval");
          figureChoice.addItem("Filled RoundRect");
          figureChoice.setBackground(Color.white);
          choiceBar.add(figureChoice);
       }  // end init()
       public Insets getInsets() {
              // Specify how wide a border to leave around the edges of the applet.
          return new Insets(3,3,3,3);
       private class Display extends JPanel
                  implements MouseListener, MouseMotionListener, ActionListener {
               // Nested class Display represents the drawing surface of the
               // applet.  It lets the user use the mouse to draw colored curves
               // and shapes.  The current color is specified by the pop-up menu
               // colorChoice.  The current shape is specified by another pop-up menu,
               // figureChoice.  (These are instance variables in the main class.)
               // The panel also listens for action events from buttons
               // named "Clear" and "Set Background".  The "Clear" button fills
               // the panel with the current background color.  The "Set Background"
               // button sets the background color to the current drawing color and
               // then clears.  These buttons are set up in the main class.
          private final static int
                      BLACK = 0,
                      RED = 1,            // Some constants to make
                      GREEN = 2,          // the code more readable.
                      BLUE = 3,           // These numbers code for
                      CYAN = 4,           // the different drawing colors.
                      MAGENTA = 5,
                      YELLOW = 6,
                      WHITE = 7;
          private final static int
                     CURVE = 0,
                     LINE = 1,
                     RECT = 2,               // Some constants that code
                     OVAL = 3,               // for the different types of
                     ROUNDRECT = 4,          // figure the program can draw.
                     FILLED_RECT = 5,
                     FILLED_OVAL = 6,
                     FILLED_ROUNDRECT = 7;
          /* Some variables used for backing up the contents of the panel. */
          Image OSI;  // The off-screen image (created in checkOSI()).
          int widthOfOSI, heightOfOSI;  // Current width and height of OSI.  These
                                        // are checked against the size of the applet,
                                        // to detect any change in the panel's size.
                                        // If the size has changed, a new OSI is created.
                                        // The picture in the off-screen image is lost
                                        // when that happens.
          /* The following variables are used when the user is sketching a
             curve while dragging a mouse. */
          private int mouseX, mouseY;   // The location of the mouse.
          private int prevX, prevY;     // The previous location of the mouse.
          private int startX, startY;   // The starting position of the mouse.
                                        // (Not used for drawing curves.)
          private boolean dragging;     // This is set to true when the user is drawing.
          private int figure;    // What type of figure is being drawn.  This is
                                 //    specified by the figureChoice menu.
          private Graphics dragGraphics;  // A graphics context for the off-screen image,
                                          // to be used while a drag is in progress.
          private Color dragColor;  // The color that is used for the figure that is
                                    // being drawn.
          Display() {
                 // Constructor.  When this component is first created, it is set to
                 // listen for mouse events and mouse motion events from
                 // itself.  The initial background color is white.
             addMouseListener(this);
             addMouseMotionListener(this);
             setBackground(Color.white);
          private void drawFigure(Graphics g, int shape, int x1, int y1, int x2, int y2) {
                // This method is called to do ALL drawing in this applet!
                // Draws a shape in the graphics context g.
                // The shape paramter tells what kind of shape to draw.  This
                // can be LINE, RECT, OVAL, ROUNTRECT, FILLED_RECT,
                // FILLED_OVAL, or FILLED_ROUNDRECT.  (Note that a CURVE is
                // drawn by drawing multiple LINES, so the shape parameter is
                // never equal to CURVE.)  For a LINE, a line is drawn from
                // the point (x1,y1) to (x2,y2).  For other shapes,  the
                // points (x1,y1) and (x2,y2) give two corners of the shape
                // (or of a rectangle that contains the shape).
             if (shape == LINE) {
                   // For a line, just draw the line between the two points.
                g.drawLine(x1,y1,x2,y2);
                return;
             int x, y;  // Top left corner of rectangle that contains the figure.
             int w, h;  // Width and height of rectangle that contains the figure.
             if (x1 >= x2) {  // x2 is left edge
                x = x2;
                w = x1 - x2;
             else {          // x1 is left edge
                x = x1;
                w = x2 - x1;
             if (y1 >= y2) {  // y2 is top edge
                y = y2;
                h = y1 - y2;
             else {          // y1 is top edge.
                y = y1;
                h = y2 - y1;
             switch (shape) {   // Draw the appropriate figure.
                case RECT:
                   g.drawRect(x, y, w, h);
                   break;
                case OVAL:
                   g.drawOval(x, y, w, h);
                   break;
                case ROUNDRECT:
                   g.drawRoundRect(x, y, w, h, 20, 20);
                   break;
                case FILLED_RECT:
                   g.fillRect(x, y, w, h);
                   break;
                case FILLED_OVAL:
                   g.fillOval(x, y, w, h);
                   break;
                case FILLED_ROUNDRECT:
                   g.fillRoundRect(x, y, w, h, 20, 20);
                   break;
          private void repaintRect(int x1, int y1, int x2, int y2) {
                // Call repaint on a rectangle that contains the points (x1,y1)
                // and (x2,y2).  (Add a 1-pixel border along right and bottom
                // edges to allow for the pen overhang when drawing a line.)
             int x, y;  // top left corner of rectangle that contains the figure
             int w, h;  // width and height of rectangle that contains the figure
             if (x2 >= x1) {  // x1 is left edge
                x = x1;
                w = x2 - x1;
             else {          // x2 is left edge
                x = x2;
                w = x1 - x2;
             if (y2 >= y1) {  // y1 is top edge
                y = y1;
                h = y2 - y1;
             else {          // y2 is top edge.
                y = y2;
                h = y1 - y2;
             repaint(x,y,w+1,h+1);
          private void checkOSI() {
               // This method is responsible for creating the off-screen image.
               // It should be called before using the OSI.  It will make a new OSI if
               // the size of the panel changes.
             if (OSI == null || widthOfOSI != getSize().width || heightOfOSI != getSize().height) {
                    // Create the OSI, or make a new one if panel size has changed.
                OSI = null;  // (If OSI already exists, this frees up the memory.)
                OSI = createImage(getSize().width, getSize().height);
                widthOfOSI = getSize().width;
                heightOfOSI = getSize().height;
                Graphics OSG = OSI.getGraphics();  // Graphics context for drawing to OSI.
                OSG.setColor(getBackground());
                OSG.fillRect(0, 0, widthOfOSI, heightOfOSI);
                OSG.dispose();
          public void paintComponent(Graphics g) {
               // Copy the off-screen image to the screen,
               // after checking to make sure it exists.  Then,
               // if a shape other than CURVE is being drawn,
               // draw it on top of the image from the OSI.
             checkOSI();
             g.drawImage(OSI, 0, 0, this);
             if (dragging && figure != CURVE) {
                g.setColor(dragColor);
                drawFigure(g,figure,startX,startY,mouseX,mouseY);
          public void actionPerformed(ActionEvent evt) {
                  // Respond when the user clicks on a button.  The
                  // command must be either "Clear" or "Set Background".
             String command = evt.getActionCommand();
             checkOSI();
             if (command.equals("Set Background")) {
                    // Set background color before clearing.
                    // Change the selected color so it is different
                    // from the background color.
                setBackground(getCurrentColor());
                if (colorChoice.getSelectedIndex() == BLACK)
                   colorChoice.setSelectedIndex(WHITE);
                else
                   colorChoice.setSelectedIndex(BLACK);
             Graphics g = OSI.getGraphics();
             g.setColor(getBackground());
             g.fillRect(0,0,getSize().width,getSize().height);
             g.dispose();
             repaint();
          private Color getCurrentColor() {
                   // Check the colorChoice menu to find the currently
                   // selected color, and return the appropriate color
                   // object.
             int currentColor = colorChoice.getSelectedIndex();
             switch (currentColor) {
                case BLACK:
                   return Color.black;
                case RED:
                   return Color.red;
                case GREEN:
                   return Color.green;
                case BLUE:
                   return Color.blue;
                case CYAN:
                   return Color.cyan;
                case MAGENTA:
                   return Color.magenta;
                case YELLOW:
                   return Color.yellow;
                default:
                   return Color.white;
          public void mousePressed(MouseEvent evt) {
                  // This is called when the user presses the mouse on the
                  // panel.  This begins a draw operation in which the user
                  // sketches a curve or draws a shape.  (Note that curves
                  // are handled differently from other shapes.  For CURVE,
                  // a new segment of the curve is drawn each time the user
                  // moves the mouse.  For the other shapes, a "rubber band
                  // cursor" is used.  That is, the figure is drawn between
                  // the starting point and the current mouse location.)
             if (dragging == true)  // Ignore mouse presses that occur
                 return;            //    when user is already drawing a curve.
                                    //    (This can happen if the user presses
                                    //    two mouse buttons at the same time.)
             prevX = startX = evt.getX();  // Save mouse coordinates.
             prevY = startY = evt.getY();
             figure = figureChoice.getSelectedIndex();
             dragColor = getCurrentColor();        
             dragGraphics = OSI.getGraphics();
             dragGraphics.setColor(dragColor);
             dragging = true;  // Start drawing.
          } // end mousePressed()
          public void mouseReleased(MouseEvent evt) {
                  // Called whenever the user releases the mouse button.
                  // If the user was drawing a shape, we make the shape
                  // permanent by drawing it to the off-screen image.
              if (dragging == false)
                 return;  // Nothing to do because the user isn't drawing.
              dragging = false;
              mouseX = evt.getX();
              mouseY = evt.getY();
              if (figure == CURVE) {
                     // A CURVE is drawn as a series of LINEs
                  drawFigure(dragGraphics,LINE,prevX,prevY,mouseX,mouseY);
                  repaintRect(prevX,prevY,mouseX,mouseY);
              else if (figure == LINE) {
                 repaintRect(startX,startY,prevX,prevY);
                 if (mouseX != startX || mouseY != startY) {
                       // Draw the line only if it has non-zero length.
                    drawFigure(dragGraphics,figure,startX,startY,mouseX,mouseY);
                    repaintRect(startX,startY,mouseX,mouseY);
              else {
                 repaintRect(startX,startY,prevX,prevY);
                 if (mouseX != startX && mouseY != startY) {
                       // Draw the shape only if both its height
                       // and width are both non-zero.
                    drawFigure(dragGraphics,figure,startX,startY,mouseX,mouseY);
                    repaintRect(startX,startY,mouseX,mouseY);
              dragGraphics.dispose();
              dragGraphics = null;
          public void mouseDragged(MouseEvent evt) {
                   // Called whenever the user moves the mouse while a mouse button
                   // is down.  If the user is drawing a curve, draw a segment of
                   // the curve on the off-screen image, and repaint the part
                   // of the panel that contains the new line segment.  Otherwise,
                   // just call repaint and let paintComponent() draw the shape on
                   // top of the picture in the off-screen image.
              if (dragging == false)
                 return;  // Nothing to do because the user isn't drawing.
              mouseX = evt.getX();   // x-coordinate of mouse.
              mouseY = evt.getY();   // y=coordinate of mouse.
              if (figure == CURVE) {
                     // A CURVE is drawn as a series of LINEs.
                 drawFigure(dragGraphics,LINE,prevX,prevY,mouseX,mouseY);
                 repaintRect(prevX,prevY,mouseX,mouseY);
              else {
                    // Repaint two rectangles:  The one that contains the previous
                    // version of the figure, and the one that will contain the
                    // new version.  The first repaint is necessary to restore
                    // the picture from the off-screen image in that rectangle.
                 repaintRect(startX,startY,prevX,prevY);
                 repaintRect(startX,startY,mouseX,mouseY);
              prevX = mouseX;  // Save coords for the next call to mouseDragged or mouseReleased.
              prevY = mouseY;
          } // end mouseDragged.
          public void mouseEntered(MouseEvent evt) { }   // Some empty routines.
          public void mouseExited(MouseEvent evt) { }    //    (Required by the MouseListener
          public void mouseClicked(MouseEvent evt) { }   //    and MouseMotionListener
          public void mouseMoved(MouseEvent evt) { }     //    interfaces).
       } // end nested class Display
    } // end class SimplePaint3

    Im quite the novice, how exactly do I go about doing that. What I did was to put both in diff files but I got errors saying that they cant find colorChoice, figureChoice in the Display class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Simple extends JFrame implements Display{
            // The main applet class simply sets up the applet.  Most of the
            // work is done in the Display class.
       JComboBox colorChoice, figureChoice;  // Pop-up menus, defined as instance
                                             // variables so that the Display
                                             // class can see them.
       public void init() {
          setBackground(Color.gray);
          getContentPane().setBackground(Color.gray);
          Display canvas = new Display();  // The drawing area.
          getContentPane().add(canvas,BorderLayout.CENTER);
          JPanel buttonBar = new JPanel();       // A panel to hold the buttons.
          buttonBar.setBackground(Color.gray);
          getContentPane().add(buttonBar, BorderLayout.SOUTH);
          JPanel choiceBar = new JPanel();       // A panel to hole the pop-up menus
          choiceBar.setBackground(Color.gray);
          getContentPane().add(choiceBar, BorderLayout.NORTH);
          JButton fill = new JButton("Set Background");  // The first button.
          fill.addActionListener(canvas);
          buttonBar.add(fill);
          JButton clear = new JButton("Clear");   // The second button.
          clear.addActionListener(canvas);
          buttonBar.add(clear);
          colorChoice = new JComboBox();  // The pop-up menu of colors.
          colorChoice.addItem("Black");
          colorChoice.addItem("Red");
          colorChoice.addItem("Green");
          colorChoice.addItem("Blue");
          colorChoice.addItem("Cyan");
          colorChoice.addItem("Magenta");
          colorChoice.addItem("Yellow");
          colorChoice.addItem("White");
          colorChoice.setBackground(Color.white);
          choiceBar.add(colorChoice);
          figureChoice = new JComboBox();  // The pop-up menu of shapes.
          figureChoice.addItem("Curve");
          figureChoice.addItem("Straight Line");
          figureChoice.addItem("Rectangle");
          figureChoice.addItem("Oval");
          figureChoice.addItem("RoundRect");
          figureChoice.addItem("Filled Rectangle");
          figureChoice.addItem("Filled Oval");
          figureChoice.addItem("Filled RoundRect");
          figureChoice.setBackground(Color.white);
          choiceBar.add(figureChoice);
       }  // end init()
    } // end class SimplePaint3
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Display extends JPanel
                  implements MouseListener, MouseMotionListener, ActionListener {
               // Nested class Display represents the drawing surface of the
               // applet.  It lets the user use the mouse to draw colored curves
               // and shapes.  The current color is specified by the pop-up menu
               // colorChoice.  The current shape is specified by another pop-up menu,
               // figureChoice.  (These are instance variables in the main class.)
               // The panel also listens for action events from buttons
               // named "Clear" and "Set Background".  The "Clear" button fills
               // the panel with the current background color.  The "Set Background"
               // button sets the background color to the current drawing color and
               // then clears.  These buttons are set up in the main class.
          private final static int
                      BLACK = 0,
                      RED = 1,            // Some constants to make
                      GREEN = 2,          // the code more readable.
                      BLUE = 3,           // These numbers code for
                      CYAN = 4,           // the different drawing colors.
                      MAGENTA = 5,
                      YELLOW = 6,
                      WHITE = 7;
          private final static int
                     CURVE = 0,
                     LINE = 1,
                     RECT = 2,               // Some constants that code
                     OVAL = 3,               // for the different types of
                     ROUNDRECT = 4,          // figure the program can draw.
                     FILLED_RECT = 5,
                     FILLED_OVAL = 6,
                     FILLED_ROUNDRECT = 7;
          /* Some variables used for backing up the contents of the panel. */
          Image OSI;  // The off-screen image (created in checkOSI()).
          int widthOfOSI, heightOfOSI;  // Current width and height of OSI.  These
                                        // are checked against the size of the applet,
                                        // to detect any change in the panel's size.
                                        // If the size has changed, a new OSI is created.
                                        // The picture in the off-screen image is lost
                                        // when that happens.
          /* The following variables are used when the user is sketching a
             curve while dragging a mouse. */
          private int mouseX, mouseY;   // The location of the mouse.
          private int prevX, prevY;     // The previous location of the mouse.
          private int startX, startY;   // The starting position of the mouse.
                                        // (Not used for drawing curves.)
          private boolean dragging;     // This is set to true when the user is drawing.
          private int figure;    // What type of figure is being drawn.  This is
                                 //    specified by the figureChoice menu.
          private Graphics dragGraphics;  // A graphics context for the off-screen image,
                                          // to be used while a drag is in progress.
          private Color dragColor;  // The color that is used for the figure that is
                                    // being drawn.
          Display() {
                 // Constructor.  When this component is first created, it is set to
                 // listen for mouse events and mouse motion events from
                 // itself.  The initial background color is white.
             addMouseListener(this);
             addMouseMotionListener(this);
             setBackground(Color.white);
          private void drawFigure(Graphics g, int shape, int x1, int y1, int x2, int y2) {
                // This method is called to do ALL drawing in this applet!
                // Draws a shape in the graphics context g.
                // The shape paramter tells what kind of shape to draw.  This
                // can be LINE, RECT, OVAL, ROUNTRECT, FILLED_RECT,
                // FILLED_OVAL, or FILLED_ROUNDRECT.  (Note that a CURVE is
                // drawn by drawing multiple LINES, so the shape parameter is
                // never equal to CURVE.)  For a LINE, a line is drawn from
                // the point (x1,y1) to (x2,y2).  For other shapes,  the
                // points (x1,y1) and (x2,y2) give two corners of the shape
                // (or of a rectangle that contains the shape).
             if (shape == LINE) {
                   // For a line, just draw the line between the two points.
                g.drawLine(x1,y1,x2,y2);
                return;
             int x, y;  // Top left corner of rectangle that contains the figure.
             int w, h;  // Width and height of rectangle that contains the figure.
             if (x1 >= x2) {  // x2 is left edge
                x = x2;
                w = x1 - x2;
             else {          // x1 is left edge
                x = x1;
                w = x2 - x1;
             if (y1 >= y2) {  // y2 is top edge
                y = y2;
                h = y1 - y2;
             else {          // y1 is top edge.
                y = y1;
                h = y2 - y1;
             switch (shape) {   // Draw the appropriate figure.
                case RECT:
                   g.drawRect(x, y, w, h);
                   break;
                case OVAL:
                   g.drawOval(x, y, w, h);
                   break;
                case ROUNDRECT:
                   g.drawRoundRect(x, y, w, h, 20, 20);
                   break;
                case FILLED_RECT:
                   g.fillRect(x, y, w, h);
                   break;
                case FILLED_OVAL:
                   g.fillOval(x, y, w, h);
                   break;
                case FILLED_ROUNDRECT:
                   g.fillRoundRect(x, y, w, h, 20, 20);
                   break;
          private void repaintRect(int x1, int y1, int x2, int y2) {
                // Call repaint on a rectangle that contains the points (x1,y1)
                // and (x2,y2).  (Add a 1-pixel border along right and bottom
                // edges to allow for the pen overhang when drawing a line.)
             int x, y;  // top left corner of rectangle that contains the figure
             int w, h;  // width and height of rectangle that contains the figure
             if (x2 >= x1) {  // x1 is left edge
                x = x1;
                w = x2 - x1;
             else {          // x2 is left edge
                x = x2;
                w = x1 - x2;
             if (y2 >= y1) {  // y1 is top edge
                y = y1;
                h = y2 - y1;
             else {          // y2 is top edge.
                y = y2;
                h = y1 - y2;
             repaint(x,y,w+1,h+1);
          private void checkOSI() {
               // This method is responsible for creating the off-screen image.
               // It should be called before using the OSI.  It will make a new OSI if
               // the size of the panel changes.
             if (OSI == null || widthOfOSI != getSize().width || heightOfOSI != getSize().height) {
                    // Create the OSI, or make a new one if panel size has changed.
                OSI = null;  // (If OSI already exists, this frees up the memory.)
                OSI = createImage(getSize().width, getSize().height);
                widthOfOSI = getSize().width;
                heightOfOSI = getSize().height;
                Graphics OSG = OSI.getGraphics();  // Graphics context for drawing to OSI.
                OSG.setColor(getBackground());
                OSG.fillRect(0, 0, widthOfOSI, heightOfOSI);
                OSG.dispose();
          public void paintComponent(Graphics g) {
               // Copy the off-screen image to the screen,
               // after checking to make sure it exists.  Then,
               // if a shape other than CURVE is being drawn,
               // draw it on top of the image from the OSI.
             checkOSI();
             g.drawImage(OSI, 0, 0, this);
             if (dragging && figure != CURVE) {
                g.setColor(dragColor);
                drawFigure(g,figure,startX,startY,mouseX,mouseY);
          public void actionPerformed(ActionEvent evt) {
                  // Respond when the user clicks on a button.  The
                  // command must be either "Clear" or "Set Background".
             String command = evt.getActionCommand();
             checkOSI();
             if (command.equals("Set Background")) {
                    // Set background color before clearing.
                    // Change the selected color so it is different
                    // from the background color.
                setBackground(getCurrentColor());
                if (colorChoice.getSelectedIndex() == BLACK)
                   colorChoice.setSelectedIndex(WHITE);
                else
                   colorChoice.setSelectedIndex(BLACK);
             Graphics g = OSI.getGraphics();
             g.setColor(getBackground());
             g.fillRect(0,0,getSize().width,getSize().height);
             g.dispose();
             repaint();
          private Color getCurrentColor() {
                   // Check the colorChoice menu to find the currently
                   // selected color, and return the appropriate color
                   // object.
             int currentColor = colorChoice.getSelectedIndex();
             switch (currentColor) {
                case BLACK:
                   return Color.black;
                case RED:
                   return Color.red;
                case GREEN:
                   return Color.green;
                case BLUE:
                   return Color.blue;
                case CYAN:
                   return Color.cyan;
                case MAGENTA:
                   return Color.magenta;
                case YELLOW:
                   return Color.yellow;
                default:
                   return Color.white;
          public void mousePressed(MouseEvent evt) {
                  // This is called when the user presses the mouse on the
                  // panel.  This begins a draw operation in which the user
                  // sketches a curve or draws a shape.  (Note that curves
                  // are handled differently from other shapes.  For CURVE,
                  // a new segment of the curve is drawn each time the user
                  // moves the mouse.  For the other shapes, a "rubber band
                  // cursor" is used.  That is, the figure is drawn between
                  // the starting point and the current mouse location.)
             if (dragging == true)  // Ignore mouse presses that occur
                 return;            //    when user is already drawing a curve.
                                    //    (This can happen if the user presses
                                    //    two mouse buttons at the same time.)
             prevX = startX = evt.getX();  // Save mouse coordinates.
             prevY = startY = evt.getY();
             figure = figureChoice.getSelectedIndex();
             dragColor = getCurrentColor();        
             dragGraphics = OSI.getGraphics();
             dragGraphics.setColor(dragColor);
             dragging = true;  // Start drawing.
          } // end mousePressed()
          public void mouseReleased(MouseEvent evt) {
                  // Called whenever the user releases the mouse button.
                  // If the user was drawing a shape, we make the shape
                  // permanent by drawing it to the off-screen image.
              if (dragging == false)
                 return;  // Nothing to do because the user isn't drawing.
              dragging = false;
              mouseX = evt.getX();
              mouseY = evt.getY();
              if (figure == CURVE) {
                     // A CURVE is drawn as a series of LINEs
                  drawFigure(dragGraphics,LINE,prevX,prevY,mouseX,mouseY);
                  repaintRect(prevX,prevY,mouseX,mouseY);
              else if (figure == LINE) {
                 repaintRect(startX,startY,prevX,prevY);
                 if (mouseX != startX || mouseY != startY) {
                       // Draw the line only if it has non-zero length.
                    drawFigure(dragGraphics,figure,startX,startY,mouseX,mouseY);
                    repaintRect(startX,startY,mouseX,mouseY);
              else {
                 repaintRect(startX,startY,prevX,prevY);
                 if (mouseX != startX && mouseY != startY) {
                       // Draw the shape only if both its height
                       // and width are both non-zero.
                    drawFigure(dragGraphics,figure,startX,startY,mouseX,mouseY);
                    repaintRect(startX,startY,mouseX,mouseY);
              dragGraphics.dispose();
              dragGraphics = null;
          public void mouseDragged(MouseEvent evt) {
                   // Called whenever the user moves the mouse while a mouse button
                   // is down.  If the user is drawing a curve, draw a segment of
                   // the curve on the off-screen image, and repaint the part
                   // of the panel that contains the new line segment.  Otherwise,
                   // just call repaint and let paintComponent() draw the shape on
                   // top of the picture in the off-screen image.
              if (dragging == false)
                 return;  // Nothing to do because the user isn't drawing.
              mouseX = evt.getX();   // x-coordinate of mouse.
              mouseY = evt.getY();   // y=coordinate of mouse.
              if (figure == CURVE) {
                     // A CURVE is drawn as a series of LINEs.
                 drawFigure(dragGraphics,LINE,prevX,prevY,mouseX,mouseY);
                 repaintRect(prevX,prevY,mouseX,mouseY);
              else {
                    // Repaint two rectangles:  The one that contains the previous
                    // version of the figure, and the one that will contain the
                    // new version.  The first repaint is necessary to restore
                    // the picture from the off-screen image in that rectangle.
                 repaintRect(startX,startY,prevX,prevY);
                 repaintRect(startX,startY,mouseX,mouseY);
              prevX = mouseX;  // Save coords for the next call to mouseDragged or mouseReleased.
              prevY = mouseY;
          } // end mouseDragged.
          public void mouseEntered(MouseEvent evt) { }   // Some empty routines.
          public void mouseExited(MouseEvent evt) { }    //    (Required by the MouseListener
          public void mouseClicked(MouseEvent evt) { }   //    and MouseMotionListener
          public void mouseMoved(MouseEvent evt) { }     //    interfaces).
       } // end nested class Display

  • Showing values beside html5 slider

    I have a page layout that I rather not break, and on the particular page (http://www.evolvedtools.com/hardwareTools.html) I have a range slider that I have been playing with.
    I have been looking at some examples where people have been able to constantly display the value of the slider, alongside the handle , as it is being moved. The values are not what's important for now, but rather the implementation in my existing code. I am not willing to restructure my whole page to fit it in.
    In the code for my page I have commented out the code for a "bubble" solution I picked up on the net. It produces a little container that is supposed to follow the  range slider and display  a value for it. It doesn't work for me though, and I am not all that surprised, as I guess the implementation is a little bit more difficult in my case than the example..... ( Example: http://css-tricks.com/value-bubbles-for-range-inputs/) I see that it makes use of webkit elements also, which I don't like...
    So my question is: Where would I have to go from here to implement such a feature ?
    page HTML:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hardware Tools</title>
    <link href="evolvedMobile.css" rel="stylesheet" type="text/css" media="only screen and (min-width: 0px) and (max-width: 650px)" id="stylesheet-650" />
    <link href="evolvedTablet.css" rel="stylesheet" type="text/css" media="only screen and (min-width: 651px) and (max-width: 1000px)" id="stylesheet-800" />
    <link href="oneColLiqCtr.css" rel="stylesheet" type="text/css" media="only screen and (min-width: 1001px)" id="stylesheet-1920" />
    <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
    <Script type="text/javascript" src="respond.min.js"></Script>
    <script src="SpryAssets/SpryEffects.js" type="text/javascript"></script>
    <Script type="text/javascript" src="Javascript Cookie Script.js"></Script>
    <script type="text/javascript">
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    function MM_effectAppearFade(targetElement, duration, from, to, toggle)
        Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    </script>
    <style type="text/css">
    body,td,th {
        font-size: 0.70em;
        font-family: "Arial Black", Gadget, sans-serif;
    </style>
    </head>
    <body bgcolor="#000000" onload="MM_preloadImages('images/HomeMainBlank2_03.png','images/HomeButton_03.png','images/ToolingButtonBlank2_07.png','images/BlogBlankM_07.png','images/Script_07.png','images/PluginTheory_05.png','images/flashBack_12.png','images/umlPage_12.png')">
    <div class="TabWrapContent" id="wrapperExt">
    <div id="homebutton"><a href="index.html" onmouseover="MM_swapImage('homebutton','','images/HomeButton_03.png',1)"onMouseOut="Set_Cookie('homeHardware','TRUE','','','','')"><img src="images/HomeMainBlank2_03.png" alt="HomeMain" name="homebutton" width="138" height="55" border="0" class="AllElements" id="homebutton2" /></a></div>
    <div id="PluginM"><a href="PluginT.html" onmouseover="MM_swapImage('PluginM','','images/PluginTheory_05.png',1)"onMouseOut="Set_Cookie('PluginFromHardware','TRUE','','','','')"><img src="images/ToolingButtonBlank2_07.png" name="PluginM" width="142" height="55" border="0" class="AllElements" id="PluginM2" /></a></div>
    <div id="Scripting"><a href="ScriptsT.html" onmouseover="MM_swapImage('Scripting','','images/Script_07.png',1)"onMouseOut="Set_Cookie('ScriptingFromHardware','TRUE','','','','')"><img src="images/BlogBlankM_07.png" name="Scripting" width="135" height="55" border="0" class="AllElements" id="Scripting2" /></a></div>
    <div id="umlTools"><a href="UmlTools.html" onmouseover="MM_swapImage('umlTools','','images/umlPage_12.png',1)"onMouseOut="Set_Cookie('umlToolsFromHardware','TRUE','','','','')"><img src="images/flashBack_12.png" name="umlTools" width="125" height="55" border="0" class="AllElements" id="umlTools2" /></a></div>
    </div>
    </div>
    <div id="contentWrap">
    <div id="wrapperExt2">
    <p> </p>
    <p><span style="font-size:1em;">Hardware Tools</span> is a term I hope will seem pretty self explanatory. This page is meant for descriptions of useful hardware electronic and ergonomical tools. To get a decent workflow going it is increasingly important to multitask, even when doing art or design - work. People have preferences according to their profession or field of interest, but the designer aspect is emphasized here. Also note that I am here referring to more or less mobile solutions for the individual designer.<br />
    <br />
    Firstly, for me I have slowly come to the conclusion that your workstation(read laptop/pc) and its specs are not going to be the piece of equipment that is most importent to you. With a decent processor, graphics card and installed memory you really can squeeze A LOT out of your mid -range machine. I will take examples from my own setup here to show you what I mean, and the interconnectivity you can acchieve through peripherals. I am talking everything from tuning software, through harware add - on's, to monitors, tablets, cell phones, networks,  graphical equipment, etc..<br />
    <br />Both at home, at work and on- the- go there is increasing need for efficiency and productivity. But the large workstations are on their way out. Ordinary desktops, desktop monitors and the like have seen their glory days, and efficient computer development reduces the need for large hardware solutions. Computing is being distributed across several pieces of equipment, as opposed to being centered in a core. Mechanically, this can be seen in solutions like the ones where your average laptop has its capacity expanded by establishing an externally housed pci-express card through the laptop's expresscard slot. Storage solutions working on cloud platforms make the need for tactile storage components redundant. This eliminates a lot of permanent hardware- needs for the traveler. And then you have visual aspect with screen real estate being a keyword. As an example here I would like to refer to a brand by the name of <a href="#" onclick="MM_openBrWindow('http://www.displaylink.com','','scrollbars=yes,resizable=yes,width=625,height=625')">DisplayLink</a>. This is a company that develops solutions for USB - connected Display solutions, like portable monitors. They make use of their own graphic adapters in the hardware, so you are not limited to the ordinary 1 extra display per standard workstation. With USB 3.0 making its presence felt, the bandwith will allow these solutions to get even better. This is of course due to the higher bandwidth that the new USB provides. On a regular pc you can connect up to 6 USB displays, and 4 for the Mac. On Windows multipoint server up to 14 displays are supported. This is of course without counting the extra displays supported by your graphics card/s. The ingenious thing about these products is the way they relieve the stress on your main hardware in that they distribute the graphics computing to several instances. This means you do not have to have a powerhouse pc to be productive on more than two displays. The graphics adapters rely on your internal cpu, but do not need much else. Hook up to any HDMI or DVI monitor or projector anywhere instead of dragging things around with you. I strongly suggest checking out their page and their products(DisplayLink), and see which products they have avaiable for your region. <br />I am currently using several DL-3500 chip graphics adapters for 1920x1200 monitors connected to my laptop. They are small and handy and I can take them with me and hook them up anywhere for more screen real estate. The difference between the fluidity of a usb 3.0 monitor setup and a usb 2.0 one is quite noticable. The adapters are really pretty gentle on your processor though, so no big worries there. I know other companies have produced solutions for multiple monitors earlier, but those looking for extensive monitor setup nowadays should test a multi monitor usb 3.0 hub from DisplayLink. And if you are going to the desolute place that doesn't have any kind of stationary monitors available you can always get one of the highly affordable, portable USB displays(Also Displaylink) and put it in you backpack. But we don't have to stop there. Finally good ultra - portable projectors with HD - resolution have started to hit the market, and I mean projectors that both have decent spesifications, are extremely portable and don't have lamps that have to be changed. Brightness, colors and resolution have usually been poor in these kind of devices, but the bar has been raised.<br />
    <br />So what else would a nomad designer need ? Well, for one thing touch would be nice! And while we're at it, graphical capabilities would also be something many would crave. So lets have a look at the options. If you are using a internet tablet with touch( Android or ios), you can now use it as an extended desktop. A lot of tablets have something called a ADB composite interface(Android Debug Bridge), which is a way for your computer to interact with your tablets file system. It is also a way of enabling software developers to make applications that let you control your computer from your tablet, not only your tablet from your computer. An example is the software application <a href="#" onclick="MM_openBrWindow('http://www.shapeservices.com/en/products/details.php?product=idisplay&platform=android','','scrollbars=yes,resizable=yes,width=625,height=625')">IDisplay</a> from Shapeservices, which lets you connect your tablet via the composite USB cabel and use your tablet as an extended desktop. The nice thing about this is that you can use input from your tablet(Touch with fingers, stylus pen, keyboard, mouse) to control applications on your computers operative system. While graphically this is mostly for sketching, it can also be used succsessfully in other applications. Also this software enables you to connect through any wireless connection, so you are not limited to the composite cable if you don't have it. Which brings me to the point of networks.<br />
    <br />4G wireless modems have hit the market some time ago, but they are not limited to a dongle in the side of your laptop. In fact they can and will feed your whole household with an internet connection if you use it right. Simple as this: Almost all routers use linux software, so the problem has been developing drivers for using the USB 4g dongles with a USB - enabled router. I am currently very successfully using a <a href="#" onclick="MM_openBrWindow('http://www.draytek.com/user/PdInfoDetail.php?Id=121','','scrollbars=yes,resizable=yes,width=625,height=625')">Draytek</a> Vigorfly200 802.11b/g/n router connected to my Netcom 4g dongle, and besides being fast I can take it with me everywhere and (depending on location) still get the same fast speed for everyone to use. If you are streaming or connecting devices wirelessly, this is gold! They have written drivers for 4g dongles, so a firmware update does all the work for you.<br />
    <br />But, returning to graphic designer work, there are some options that I feel have completely erased the need for things like the traditional paper - based drawing surface. The reason I am saying this is that these tools are so precise and make the transition from computer to drawing so minimal, that the thought process of designing/programming/sketching becomes a lot more interesting and intuitive. The problem with relatively great products earlier that use a separate mat surface for drawing, separate from the screen, is the hand/eye coordination. I have used one myself and still occasionally do, but there is no question whatsoever that seeing the direct result of your brush stroke without having to move your eyes one way or the other is a better way of interacting with your work. Why drive your car with a remote control if you can sit inside ? Let's go straight to the products, and you can judge for yourself. The king of the hill is as of now the <a href="#" onclick="MM_openBrWindow('http://www.wacom.com/en/Products/Cintiq.aspx','','scrollbars=yes,resizable=yes,width=625,height=625')">Wacom Cintiq 24HD</a>, which lets you draw on a supreme ergonomical- design monitor with detailing and specifications that will satisfy any business. It works also of course as an extended desktop, so again you get increased productivity. I am not going to say more, but take a look for yourself. Of course, these products are kind of pricy, but there are alternatives. Chinese Yiynova produce three notable drawing monitors in <a href="#" onclick="MM_openBrWindow('http://www.amazon.com/Brand-Yiynova-Digitizer-Tablet-Display/dp/B005EDNAPU','','scrollbars=yes,resizable=yes,width=625,height=625')">10"</a>, <a href="#" onclick="MM_openBrWindow('http://www.amazon.com/Yiynova-Monitor-MSP15-Adjustable-Support-Windows/dp/B005EIF3BY','','scrollbars=yes,resizable=yes,width=625,height=625')">15"</a> and <a href="#" onclick="MM_openBrWindow('http://www.amazon.com/Yiynova-Tablet-MSP19-19inch-1440x900/sim/B004CUT6NG/2','','scrollbars=yes,resizable=yes,width=625,height=625')">19"</a>, and while their spesifications are as good as most of the wacom's, the prices are way lower. Again, you have to decide for yourself.<br />
    <br />Moving on to add- on products, I would like to mention the standards of EsataP and USB 3.0. If you have a 2 year old mid - range machine, chances are you do not have the new USB 3.0 ports. For quite a while I have been using the esatap ( external sata powered) port on my computer for external harddisk backup. SATA is a computer bus interface for connecting host bus adapters to mass storage devices such as hard disk drives and optical drives. On a lot of laptops or desktops you have the possibility of either installing an esata card or you may have an esataP port on your laptop. What you in fact then have is a combined USB/esata port with speed that nearly rivals the new USB 3.0 standard. Using an esatap cable you can get up to 100 MBytes/s transfer speeds to or from your external drives for now. The port conncets directly to your sata harddrive, so the theoretical speed is 3GBit/s which is 375Mbytes/s, or in practice more like 300MB. If you have one of these ports I strongly suggest you use it. People have made a big deal about the need for shutting down your system before removing your esatap device, but that is completely unneccesary. I will just say <a href="#" onclick="MM_openBrWindow('http://mt-naka.com/hotswap/index_enu.htm','','scrollbars=yes,resizable=yes,width=625,height=625')">HotSwap</a>.<br />
    <br />If you have an expresscard 34 or 54 slot you can of course add an expresscard with usb 3.0 port/s, but tests show that the expresscard interface and the 2.5Gbit/s limit of your revision 1.0 or 1.1 pci-e will not give you full USB 3.0 speeds, and even if you had a revision 2.0 or later (5GBit/s), you would still have to have have the ExpressCard 2.0 slot on your machine, as only this makes use of the full bandwith of the USB superspeed(3.0). With the more ordinary ExpressCard 1.0 slot you still get 2.5 GBit/s which is actually very much faster than USB 2.0.<br /> 
    <br /> More to follow.....</p>
    </div>
    </div>
        <div class="slider" input type="range" name="eivi" max="-6" min="2000" step="1" value="0">
        <div class="progress" style="width: 3px;"></div>
        <a class="handle" style="top: 0px;"></a>
    </div>
    <!--<div class="output">
        <output for="eivi" onforminput="value"></output>
    </div>-->
    <script type="text/javascript">
    // get handle to the scrollable DIV
    var wrapperExt2 = $("#wrapperExt2");
    // initialize rangeinput
    $(":range").rangeinput({
    // slide the DIV along with the range using jQuery's css() method
    onSlide: function(ev, step) {
    wrapperExt2.css({bottom: step});
    // display progressbar
    progress: true,
    // initial value. also sets the DIV's initial scroll position
    value: 0,
    // this is called when the slider is clicked. we animate the DIV
    change: function(e, i) {
    wrapperExt2.animate({bottom: i}, "fast");
    // disable drag handle animation when when slider is clicked
    speed: 0
    </script>
    <script type="text/javascript">
    $(function() {
    var el, newPoint, newPlace, offset;
    // Select all range inputs, watch for change
    $("input[type='range']").change(function() {
       // Cache this for efficiency
       el = $(this);
       // Measure width of range input
       height = el.height();
       // Figure out placement percentage between left and right of input
       newPoint = (el.val() - el.attr("min")) / (el.attr("max") - el.attr("min"));
       // Janky value to get pointer to line up better
       offset = -1.3;
       // Prevent bubble from going beyond left or right (unsupported browsers)
       if (newPoint < 0) { newPlace = 0; }
       else if (newPoint > 1) { newPlace = height; }
       else { newPlace = width * newPoint + offset; offset -= newPoint; }
       // Move bubble
       el
         .next("output")
         .css({
           top: newPlace,
           marginLeft: offset + "%"
         .text(el.val());
    // Fake a change to position bubble at page load
    .trigger('change');
    </script> */
    <script type="text/javascript">
      if (Get_Cookie('homeHardware')) { document.getElementById('homebutton2').src="images/HomeButton_03.png" ; }
    if (Get_Cookie('PluginFromHardware')) { document.getElementById('PluginM2').src="images/PluginTheory_05.png" ; }
    if (Get_Cookie('ScriptingFromHardware')) { document.getElementById('Scripting2').src="images/Script_07.png" ; }
      if (Get_Cookie('umlToolsFromHardware')) { document.getElementById('umlTools2').src="images/umlPage_12.png" ; }
    </script>
    </body>
    </html>
    CSS ( for the "bubble element"):
    /*.output {
        position: absolute;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444444), to(#999999));
    background-image: -webkit-linear-gradient(top, #444444, #999999);
    background-image: -moz-linear-gradient(top, #444444, #999999);
    background-image: -ms-linear-gradient(top, #444444, #999999);
    background-image: -o-linear-gradient(top, #444444, #999999);
        width: 30px;
        height: 40px;
        text-align: center;
        color: white;
        border-radius: 10px;
        display: inline-block;
        font: bold 15px/30px Georgia;
        top: 50%;
        left: 100%;
        margin-top: -195px;
        margin-right: -185px;
        margin-bottom: 1%;
        margin-left: -180px;
        /*bottom: 175%;
      left: 0;
      margin-left: -1%; */
    .output:after {
      content: "";
      position: absolute;
      width: 0;
      height: 0;
      border-top: 10px solid #999999;
      border-left: 5px solid transparent;
      border-right: 5px solid transparent;
      top: 100%;
      left: 50%;
    margin-left: -5px;
      margin-top: -1px;

    I would use jQuery UI Slider for this -- click on examples for other options.
    http://jqueryui.com/demos/slider/#slider-vertical
    Nancy O.

  • Java APP inside a Win32 Window

    Hello,
    Q1: I need to embed a complete java swing application inside an existing win32 application window (I have the HWND of it).
    How to do this ?
    Q2: Is it possible to set the native Win32 parent window of a JFrame with JNI ?
    Cheers,
    Mik

    This can be done, but is a little complicated.
    Firstly create a subclass of Canvas, with the following native method
    JNIEXPORT jlong JNICALL MyCanvas_getWindowInfo( JNIEnv *env, jobject canvas )
         JAWT      awt;
         jlong   handle      = 0;
         // Get the AWT
         awt.version = JAWT_VERSION_1_3;
         if( JAWT_GetAWT( env, &awt ) == JNI_TRUE )
              // Get the drawing surface
              JAWT_DrawingSurface     *ds = awt.GetDrawingSurface( env, canvas );
              if( ds )
                   // Lock the drawing surface
                   jint lock = ds->Lock( ds );
                   if( (lock & JAWT_LOCK_ERROR) == 0 )
                        // Get the drawing surface info
                        JAWT_DrawingSurfaceInfo     *dsi = ds->GetDrawingSurfaceInfo( ds );
                        if( dsi )
    #if WIN32
                             JAWT_Win32DrawingSurfaceInfo *info   = (JAWT_Win32DrawingSurfaceInfo *)dsi->platformInfo;
                             handle = (jlong)GetParent( info->hwnd );
    #endif
                             // Free the drawing surface info
                             ds->FreeDrawingSurfaceInfo( dsi );
                        // Unlock the drawing surface
                        ds->Unlock( ds );
                   // Free the drawing surface
                   awt.FreeDrawingSurface( ds );
         return handle;
    }Next in C, do the following
    1. Create a JWindow.
    2. Make it visible.
    3. Add an instance of MyCanvas to the JWindow.
    4. Call the getWindowInfo method, which will return the window handle of the frame.
    5. Remove the instance of MyCanvas, of make it invisible.
    6. Reparent the frame window using SetParent( handleOfApp, frameHandle );7. Change the style of the frame so it doesn't think its a top level window SetWindowLong( frameWindow, GWL_STYLE, WS_CHILD );The last step is to simply add you java frame (or whatever) to this newly created window.

  • Cannot resolve symbol java.awt.graphics

    // DrawRectangleDemo.java
    import java.awt.*;
    import java.lang.Object;
    import java.applet.Applet;
    public class DrawRectangleDemo extends Applet
         public void paint (Graphics g)
              // Get the height and width of the applet's drawing surface.
              int width = getSize ().width;
              int height = getSize ().height;
              int rectWidth = (width-50)/3;
              int rectHeight = (height-70)/2;
              int x = 5;
              int y = 5;
              g.drawRect (x, y, rectWidth, rectHeight);
              g.drawString ("drawRect", x, rectHeight + 30);
              x += rectWidth + 20;
              g.fillRect (x, y, rectWidth, rectHeight);
              // Calculate a border area with each side equal tp 25% of
              // the rectangle's width.
              int border = (int) (rectWidth * 0.25);
              // Clear 50% of the filled rectangle.
              g.clearRect (x + border, y + border,
                             rectWidth - 2 * border, rectHeight - 2 * border);
              g.drawString ("fillRect/clearRect", x, rectHeight + 30);
              x += rectWidth + 20;
              g.drawRoundRect (x, y, rectWidth, rectHeight, 15, 15);
              g.drawString ("drawRoundRect", x, rectHeight + 30);
              x=5;
              y += rectHeight + 40;
              g.setColor (Color.yellow);
              for (int i = 0; i < 4; i++)
                   g.draw3DRect (x + i * 2, y + i * 2,
                                       rectWidth - i * 4, rectHeight - i * 4, false);
              g.setColor (Color.black);
              g.drawString ("draw3DRect", x, y, + rectHeight + 25);
              x += rectWidth + 20;
              g.setColor (Color.yellow);
              g.fill3DRect (x, y, rectWidth, rectHeight, true);
              g.setColor (Color.black);
              g.drawString ("fill3DRect", x, y, + rectHeight + 25);
    Help me with this codes. I typed correctly but there still errors.
    --------------------Configuration: JDK version 1.3.1 <Default>--------------------
    D:\Program Files\Xinox Software\JCreator LE\MyProjects\DrawRectangleDemo.java:56: cannot resolve symbol
    symbol : method drawString (java.lang.String,int,int,int)
    location: class java.awt.Graphics
              g.drawString ("draw3DRect", x, y, + rectHeight + 25);
    ^
    D:\Program Files\Xinox Software\JCreator LE\MyProjects\DrawRectangleDemo.java:64: cannot resolve symbol
    symbol : method drawString (java.lang.String,int,int,int)
    location: class java.awt.Graphics
              g.drawString ("fill3DRect", x, y, + rectHeight + 25);
    ^
    2 errors
    Process completed.
    -------------------------------------------------------------------------------------------------------------------------------

    cannot resolve symbol
    symbol : method drawString (java.lang.String,int,int,int)
    This is telling you that you are trying to invoke the drawString() method with 4 parameters: String, int, int, int
    If you look at the API the drawString() method need 3 parameters: String, int, int - so you have an extra int
    location: class java.awt.Graphics
    g.drawString ("draw3DRect", x, y, + rectHeight + 25);
    Now is you look at your code you will find that you have 3 ',' in you method call. (I don't think you want the ',' after the y.

  • Painting on canvas in native cocoa

    Hi Friends,
    I need a make a java canvas in which i have to paint thumbnail images by native cocoa code.
    I had got drawing surface(ds) and drawing surface interface(dsi).Also i am able to read the thumbnail images but donot know how to paint images in canvas using cocoa.
    Please suggest and if possible give some example or code sample.
    Thanks in advance.

    the bare minimum to render to a fullscreen frame in the fastest way possible...
    Frame f = new Frame();
    f.getGraphicsConfiguration().getDefaultDevice().setFullScreenWindow(f);
    f.createBufferStrategy(2);
    BufferStrategy bs = f.getBufferStrategy();
    Random r = new Random();
    while(true)
       Graphics g = bs.getDrawGraphics();
       g.setColor(new Color(r.nextInt));
       g.fillRect(0,0,getWidth(),getHeight());
       g.dispose();
       bs.show();
    }

  • Problems with hooking

    I've come across an interesting situation which I'm lost in. I'm trying to hook into an application via to check for mouse clicks. I have that portion of the code working with what I have. My comparison comes from the handle of the window I want to click on:
    //mtitle is the title of the window in Java
    HWND fwnd = FindWindowA(NULL, mtitle);That's all fine and dandy if I'm working with a JFrame, but I wanted to take it a step farther and try it with a Panel, so I came across this:
       //container is a jobject being passed in from java.
       HWND hwnd;  
       jboolean result;
       if(container == NULL)
          return false;
       //get the awt
       awt.version = JAWT_VERSION_1_3;
       result = JAWT_GetAWT(env, &awt);
       if(!result)
          return false;
       JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, container);
       if(ds == NULL)
          return false;
       //get the drawing surface info
       JAWT_DrawingSurfaceInfo* dsi = NULL;
       try {
          dsi = ds->GetDrawingSurfaceInfo(ds);     
       } catch (...) {
          return false;
       if(dsi == NULL)
          return false;
       // Lock the drawing surface
       jint lock = ds->Lock(ds);
       // Get the platform-specific drawing info
       JAWT_Win32DrawingSurfaceInfo* dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
       if(dsi_win == NULL)
          return false;
       hwnd = dsi_win->hwnd;
       // Free the drawing surface info
       ds->FreeDrawingSurfaceInfo(dsi);
       // Unlock the drawing surface
       ds->Unlock(ds);
       // Free the drawing surface
       awt.FreeDrawingSurface(ds);Now, it's the same exact handle coming from the window, BUT, with this code:
    hmb = SetWindowsHookEx( WH_MOUSE, (HOOKPROC)HookMouseProc, (HINSTANCE)g_hModule, 0 );and...
    BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved )
         switch(ul_reason_for_call)
              case DLL_PROCESS_ATTACH:
             g_hModule = hModule;
                   return TRUE;
              case DLL_PROCESS_DETACH:
                   //Cleanup();
                   return TRUE;
       return TRUE;
    }it's stopping any form of messages to pass through the hook. Here's my test:
    JNIEXPORT LRESULT CALLBACK HookMouseProc(INT nCode, WPARAM wParam, LPARAM lParam)
       if (nCode < 0)  // do not process message
              return CallNextHookEx(hmb, nCode, wParam, lParam);
       Beep(4000, 10);
       return CallNextHookEx(hmb, nCode, wParam, lParam);
    }  Now it's working on every other window except the specific one I'm trying to connect to. This is only when I'm using the JAWT code. It works perfectly with the FindWindow() code. So, in the long run, is there something that stops me from hooking in properly? Any and all ideas are more then welcomed.
    Also, if you're confused by the question, let me know and I'll try to rephrase it.
    Edited by: Slutibartfast on Apr 2, 2008 1:44 PM

    DING! Found a solution. Took a good long while, but it works. I'm writing this for those in the future who want to use it:
    JNIEXPORT jboolean JNICALL Java_Interface_attachRenderHwnd(JNIEnv *env, jobject obj, jobject container) {  
       JAWT awt;
       JAWT_DrawingSurface* ds;
       JAWT_DrawingSurfaceInfo* dsi;
       JAWT_Win32DrawingSurfaceInfo* dsi_win;
       HWND handle_win;
       HMODULE _hAWT;     // JAWT module handle
       jint lock;
       *PJAWT_GETAWT pJAWT_GetAWT;  // JAWT_GetAWT function pointer*
       //Get the AWT
       *_hAWT = LoadLibraryA("jawt.dll");*
       if (!_hAWT) {
          WriteMessage("No jawt.dll... Trying awt.dll\n");
          _hAWT = LoadLibraryA("awt.dll");   // IBM Java 1.3.x packages JAWT_GetAWT in awt.dll
       if (!_hAWT) {
         WriteMessage("JAWT DLL Not Found\n");
         return JNI_FALSE;
       pJAWT_GetAWT = (PJAWT_GETAWT)GetProcAddress(_hAWT, "_JAWT_GetAWT@8");
       if (!pJAWT_GetAWT) {
         WriteMessage("JAWT_GetAWT Entry Not Found\n");
       FreeLibrary(_hAWT);
       return JNI_FALSE;
       awt.version = JAWT_VERSION_1_3;
       if (pJAWT_GetAWT(env, &awt) == JNI_FALSE) {
         WriteMessage("AWT Not Found\n");
         FreeLibrary(_hAWT);
         return JNI_FALSE;
       //Get the Drawing Surface
       ds = awt.GetDrawingSurface(env, container);
       if (ds == NULL) {
         WriteMessage("NULL Drawing Surface\n");    
         FreeLibrary(_hAWT);
         return JNI_FALSE;
       //Lock the Drawing Surface
       lock = ds->Lock(ds);
       if ((lock & JAWT_LOCK_ERROR) != 0) {
         WriteMessage("Error Locking Surface\n");    
         awt.FreeDrawingSurface(ds);
         FreeLibrary(_hAWT);
         return JNI_FALSE;
       //Get the Drawing Surface info
       dsi = ds->GetDrawingSurfaceInfo(ds);
       if (dsi == NULL) {
         WriteMessage("Error Getting Surface Info\n");
         ds->Unlock(ds);
         awt.FreeDrawingSurface(ds);
         FreeLibrary(_hAWT);
         return JNI_FALSE;
       //Get the Platform specific Drawing Info
       dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
       //Get the Handle to the Native Drawing Surface info
       handle_win = (HWND) dsi_win->hwnd;
       //Clean up after us
       ds->FreeDrawingSurfaceInfo(dsi);
       ds->Unlock(ds);
       awt.FreeDrawingSurface(ds);
       FreeLibrary(_hAWT);
       AttachWindow(handle_win);
       return gIsAttached;
    }Did two things differently. Loaded from a library and had a pointer to the method instead of using it directly. Hope this'll help others in the future!

  • How to prepare results of imgGrab() for AVI output in C++?

    I hope this is an appropriate forum for this. I'm using VC++ 6.0 My image data is stored in a buffer that is populated via imgGrab(). I then go on to copy the buffer contents to a Direct Draw surface. This all works just fine.
    I am also opening an AVI file, and attempting to write this image as a frame to the file. So far I am able to open the AVI, write the correct number of frames to it at the correct dimension, and close the AVI file without failure. The problem is that all of the buffer data is being written into the top 25% of vertical space only, the remaining 75% of vertical space in my AVI frames are black.
    I'm attempting to add it as follows:
    (note, all hard-coded numeric values below are actually calculated, I've shown actual values for clarity)
    int iSize = 4000000; // (it's a 1000x1000 pixel 32bit image)
    CBitmap* pBitmap;
    pBitmap = new CBitmap();
    pBitmap->CreateBitmap(1000, 1000, 1,32, pBuffer);
    HBITMAP hbm = (HBITMAP)pBitmap->operator HBITMAP();
    HDIB pDIB = BitmapToDIB(hbm, NULL);
    if (pDIB==NULL)
    return VIDEO_DIBCONVERSION;
    if (ADD_FRAME_FROM_DIB_TO_AVI(pDIB, "DIB", 9) == FALSE)
    this attempts to add a frame based on the device independant bitmap I've created.
    The ADD_FRAME... method looks like this:
    bool ADD_FRAME_FROM_DIB_TO_AVI(HANDLE dib, CString _compressor, int _frameRate)
    LPBITMAPINFOHEADER lpbi;
    if(count == 0)
    lpbi = (LPBITMAPINFOHEADER)GlobalLock(dib);
    if(! AVI_CreateStream(pfile, &ps, _frameRate,
    (unsigned long) lpbi->biSizeImage,
    (int) lpbi->biWidth,
    (int) lpbi->biHeight))
    //printf("Error - AVI_CreateStream()\n");
    GlobalUnlock(lpbi);
    return false;
    if(! AVI_SetOptions(&ps, &psCompressed, lpbi, _compressor))
    //printf("Error - AVI_SetOptions()\n");
    GlobalUnlock(lpbi);
    return false;
    GlobalUnlock(lpbi);
    lpbi = (LPBITMAPINFOHEADER)GlobalLock(dib);
    if (lpbi)
    if(! AVI_AddFrame(psCompressed, count * 1, lpbi))
    //printf("Error - AVI_AddFrame()\n");
    GlobalUnlock(lpbi);
    return false;
    GlobalUnlock(lpbi);
    count++;
    return true;
    return false;
    I've tried doing everythign the same, but rather than actually creating the bitmap with the buffer data:
    pBitmap->CreateBitmap(1000, 1000, 1,32, pBuffer);
    I've created a CBitmap instance and loaded into it a "known good bitmap" that's actually an export from my current app.
    When I do that, I get an AVI that is X number of frames of my known good bitmap. So I'm pretty certain all the AVI setup/writing functionality is working properly, it seems something is lost in the buffer, or I'm not translating the buffer that imgGrab() is producing correctly.
    Does anybody have any suggestions?
    thanks!

    Paul,
    The example is no longer available because of its age and the fact that
    a new AVI API has since then been released.  The API is available
    for VB, and will have to be called using ActiveX for it to be used in
    C++.  The container for the AVI session is called
    CWIMAQAVISession, and the various functions can be found in the NI
    Vision for Visual Basic Reference Help in the Start menu under Programs
    >> National Instruments >> Vision >> Documentation.
    Regards,
    Mike T
    National Instruments

Maybe you are looking for