Results 1 to 4 of 4
  1. #1
    lifes46 is offline Member
    Join Date
    Mar 2011
    Posts
    4
    Rep Power
    0

    Default Bug in repaint java2d object using mouseWheelListener

    I am drawing basic java2d image like rectangle. And also implementing mouse wheel listener to zoom in and out the shape.

    Inside the action listener i adding repaint(); it doesnt clear the previous object and it keep redrawing in the APPLET. is the way to clear the applet?

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    Custom painting in a Swing application is done by overriding the paintComponent() method of a JPanel (and then you add the panel to the applet). You need to make sure you invoke super.paintComponent(g) as the first statement in your method so the background gets repainted.
    Last edited by camickr; 03-27-2011 at 04:11 PM.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default

    Your code shows no attempt to utilize the valuable advice already given by camickr. Not the best way to get further help, that.

    Also, post code in code tags -- [code]CODE[/code] will display as
    Java Code:
    CODE
    db

  4. #4
    lifes46 is offline Member
    Join Date
    Mar 2011
    Posts
    4
    Rep Power
    0

    Default

    Thanks for the advice, solved the problem by drawing the shape in panel instead of applet. Will post further codes inside [code] tag.

Similar Threads

  1. the very very very basics of java2d
    By senca in forum New To Java
    Replies: 1
    Last Post: 11-24-2010, 03:30 PM
  2. Java2D
    By Alex j in forum Java 2D
    Replies: 1
    Last Post: 04-07-2009, 04:59 PM
  3. Ebook for java2D for beginners.
    By hardiks21 in forum Java 2D
    Replies: 2
    Last Post: 02-08-2009, 12:04 PM
  4. n00b help with java2D api
    By michcio in forum Java 2D
    Replies: 7
    Last Post: 10-30-2008, 06:18 PM
  5. Demonstrating the MouseWheelListener
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 04-23-2008, 08:26 PM

Posting Permissions

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