Results 1 to 3 of 3
  1. #1
    Bestsanchez is offline Member
    Join Date
    Jan 2012
    Location
    The Coffee Pot
    Posts
    36
    Rep Power
    0

    Default Rain animation help

    Sorry no code because I attempted and it was a trainwreck so i'm back to square one. I'm just trying to create randomized rain on a jpanel by drawing lines about 4 pixels long using a Timer and actionPerformed() to do it. There's already stuff drawn on the panel so some of my thoughts are: on the same panel?, on a transparent panel on top of it?, something with an array?, use Math.random()?(I am), create lots of raindrop objects?(failed that route). I'm just looking for some suggestions or pointers in the right direction, thanks.

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

    Default Re: Rain animation help

    You are on the right track.

    Use a Swing Timer to schedule the animation. In the paintComponent() code you will probably need an ArrayList of raindrop objects that you want to paint. When the Timer fires you just invoke repaint() on the panel. Then the custom painting code will loop through the ArrayList of raindrops.

  3. #3
    Bestsanchez is offline Member
    Join Date
    Jan 2012
    Location
    The Coffee Pot
    Posts
    36
    Rep Power
    0

    Default Re: Rain animation help

    Never done an ArrayList before, time to learn haha.

Similar Threads

  1. Animation
    By ryainad in forum Advanced Java
    Replies: 1
    Last Post: 04-04-2011, 06:52 PM
  2. Fish animation
    By SwEeTAcTioN in forum AWT / Swing
    Replies: 3
    Last Post: 11-30-2009, 11:56 AM
  3. need help about animation ?
    By h9h in forum Java 2D
    Replies: 1
    Last Post: 10-30-2009, 12:41 PM
  4. JTextArea Animation
    By hoglu in forum New To Java
    Replies: 1
    Last Post: 12-18-2008, 12:44 PM
  5. GUI Animation
    By serfster in forum New To Java
    Replies: 2
    Last Post: 06-11-2008, 04:37 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
  •