draw image at mouse position
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: draw image at mouse position

Threaded View

  1. #1
    Join Date
    Nov 2011
    Posts
    189

    draw image at mouse position

    I have recently started the developement of a minigame called "toro".
    As this is my first time using graphics, i have no ideea where to start, so i'll just make a brief introduction to the program and ask you for help.
    Toro is a game in which you have to defend 5 dots against a bull, by telling the dots where to go via a cursor. The program is composed from a JPANEL inside a JFRAME .
    What i need to do is the following:
    1) Add a mouse listener on the JPANEL so i could get the coordinates of the mouse as it you click it. [done]
    2) When Clicked, the panel should display an image (100*100px if it matters) to the coordinates returned by the listener [pending]

    What i have tried:

    I know that you will not accept giving help without me trying by myself, so i'll tell you what i already tried.
    Bassically everything i tried was related to overriding paintComponent(Graphics g) , but most of it failed since my main class extends JFRAME and not JPANEL hence the inability to override paintComponent() .
    I have also tried making another class extending JPANEL , tentative which failed.

    From the tutorials I've seen i learned how to draw an image at the very beginning of the execution, but not when triggered by an event ( mouseClicked ).


    Please help me, i really dont know what to look for anymore, as i already consulted G O O G L E ! but nothing has been relevant.

    Cheers,
    -Cens
    Last edited by cens; November 8th, 2012 at 07:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center