drag to rotate

Discussion in 'Java' started by Dan Barnet, Jun 17, 2004.

  1. Dan Barnet

    Dan Barnet Guest

    Hi, I wrote my first "real" program in java.
    It is a tictactoe game in 3D.
    It seems to do what I want except for the dragging of the cube.
    Right now the cube is not redrawn when I drag, only when I release the
    mouse. I resorted to calculating a new cube display from the start-end
    drag mouse positions.

    How can I make the cube being redrawn "as I drag"?
    The applet is at http://www.milinta.com/ttt3d.html

    Dan Barnet, Jun 17, 2004
    1. Advertisements

  2. Dan Barnet

    Chris Smith Guest

    Unfortunately, there's no code there. My guess is that there's
    something interesting going on with your event handling. Presumably,
    you add a MouseListener to the applet; what does that look like?

    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Jun 17, 2004
    1. Advertisements

  3. Without the seeing the code one can only guess. Sound's like you didn't
    understand how the Java GUI event handling works. Check Sun's GUI
    tutorial, and check the comp.lang.java.gui FAQ.

    Thomas Weidenfeller, Jun 18, 2004
  4. <http://www.physci.org/codes/javafaq.jsp#cljg>
    Andrew Thompson, Jun 18, 2004
  5. Dan Barnet

    Chris Uppal Guest

    You have overridden mouseDrag() in your code, but if you look at the API docs,
    you'll see that that is deprecated since Java 1.1, so it's not surprising that
    it doesn't work. If you add a MouseMotionListener then it should work OK.


    In fact I suspect it's /really/ because the Component doesn't activate its
    emulation of the deprecated APIs unless mouse motion events are activated.
    That's why your override of the similarly deprecated mouseUp() "works" but
    mouseDrag() doesn't. You could enable those events explicitly, but it looks a
    lot easier just to go with the flow and do it "right" with a

    -- chris
    Chris Uppal, Jun 18, 2004
  6. Dan Barnet

    Roedy Green Guest

    Roedy Green, Jun 18, 2004
  7. Dan Barnet

    Dan Barnet Guest

    You (and everyone else) were right. My code was based on an older
    example. It seems to be working better now altho it certainly could be
    If you want to see what it now looks like check
    Dan Barnet, Jul 8, 2004
  8. Nice. A few useability suggestions
    for your further development.

    Inform the user textually of a win or loss.
    Perhaps also draw a new square to click
    for 'new game'

    I tried to click one square but missed
    and another was highlit (I *swear* the pointer
    was over the other one on the lower layer).
    Perhaps you should 'pulse' the color of
    the changing square for a few moments
    before considering it 'set'. If the user
    clicks any point on the board during
    that 'pulsing' time, the selection is

    Andrew Thompson, Jul 8, 2004
  9. Dan Barnet

    Dan Barnet Guest

    That was a bug (fixed now I think). If I were to release this in the
    wild (or if I had time) I'd make a few more changes. Right now I use
    the browser's status line (not always ON I know) and the top line of
    the applet to display messages.
    Thanks for your feedback.
    Dan Barnet, Jul 9, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.