Results 1 to 4 of 4
  1. #1
    KernelPanic is offline Member
    Join Date
    Apr 2012
    Posts
    16
    Rep Power
    0

    Default [Java 7 SE]Mouse Cursor like in Enginering Applications

    Dear Sirs and Madams!

    On subclassed JPanel, which is my canvas for drawing objects, I catch mouseMove event and at mouse location then I draw two line, as shown in screenshot. But, the previous mouseMove crosshair draw stays, it is not cleared. How do I draw lines at only current mouse coordinates?[Java 7 SE]Mouse Cursor like in Enginering Applications-mousemovelinesdonotvanish.png

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default Re: [Java 7 SE]Mouse Cursor like in Enginering Applications

    I'm not psychic, but it sounds like you're missing a call to super.paintComponent(). But I really can't tell without seeing an SSCCE.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    KernelPanic is offline Member
    Join Date
    Apr 2012
    Posts
    16
    Rep Power
    0

    Default Re: [Java 7 SE]Mouse Cursor like in Enginering Applications

    THANKS YOU VERY MUCH super.paintComponent() was missing.
    Now the cursor works fine!!! I know my entry post was bad, but I could not explain the problem in better way. Here is now working method for cross cursor in JPanel "Workspace": public void mouseClicked(final MouseEvent me)
    {
    this.m_iMouseXPos=(int)me.getPoint().getX();
    this.m_iMouseYPos=(int)me.getPoint().getY();

    final Graphics g=this.getGraphics();
    g.drawString("("+Integer.toString(this.m_iMouseXPo s)+", "
    +Integer.toString(this.m_iMouseYPos)+")", this.m_iMouseXPos-10,
    this.m_iMouseYPos+10);
    // g.dispose();
    }

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: [Java 7 SE]Mouse Cursor like in Enginering Applications

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 2
    Last Post: 03-10-2012, 04:26 AM
  2. Java cursor problem
    By gaj7 in forum Java Applets
    Replies: 4
    Last Post: 01-13-2012, 04:11 PM
  3. Custom Cursor Mouse
    By mistercaste in forum Java 2D
    Replies: 3
    Last Post: 03-24-2010, 08:56 PM
  4. button that runs away from the mouse cursor
    By MartinBenes71 in forum New To Java
    Replies: 1
    Last Post: 01-28-2010, 08:00 AM
  5. change the mouse cursor - crosshair cursor
    By cassysumandak in forum New To Java
    Replies: 1
    Last Post: 09-28-2009, 01:57 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
  •