Search:

Type: Posts; User: copeg

Search: Search took 0.10 seconds.

  1. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    Once again, println's will help you see the values of how much the shape is translated. Bottom line, every time the mouse is dragged the shape is dragged by the current mouse location minus the mouse...
  2. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    Octagon extends Polygon, so you should make use if its capability by calling the parent constructor. As is - although not explicit - the constructor of Octagon calls the parameter-less constructor of...
  3. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    I feel the error lies in your Octagon class, so I recommend you post that code.
  4. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    If it prints nothing, that tells you an enormous amount of information...it tells you that line of code is never reached. Since it is in the mouseDragged statement of a MouseMotionListener, what...
  5. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    When you say above the println statements 'didn't fix it', what do you mean? When you add the println statements, can you tell from what the command line prints if the code enter the mousePressed...
  6. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    System.out.println doesn't help it, System.out.println helps you. In this case, printing out values can let you know the coordinates of Shape (eg Octagon), whether the Shape contains method is...
  7. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    As I mentioned in a post above, add some System.out.println statements in your code. This will allow you to see what the values are, whether certain methods or control statements are entered,...
  8. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    Hard to tell from your post...did you add the mouseListener AND mouseMotionListener. The two are different, and must be added using the appropriate method.



    OctagonsListeners listener = new...
  9. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    Try adding the OctagonsListener as a mouseMotionlistener to your JPanel


    addMouseMotionListener(new OctagonsListener());
  10. Replies
    21
    Views
    6,308

    Re: How to drag the shape to move?

    Can you define what you mean by 'no luck'? At what point does it 'break' (dragging, drawing)? Add some println statements (or use a debugger) to make sure the mousePressed and mouseDragged are doing...
Results 1 to 10 of 10