Results 1 to 2 of 2
  1. #1
    hnchnc is offline Member
    Join Date
    Nov 2010
    Rep Power

    Default How to draw line with animation

    I need to draw a line from point A(x1,y1) to point B(x2, y2). But instead of just show the line, I need to see the line was actually drawn - little bit by little bit, at a controllable speed - from point A to point B .

    Thanks for any inputs.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    I would use Swing, draw in a JPanel's paintComponent method, have class fields x1, y1, x2, y2, and in a Swing Timer change x2 and y2 incrementally and then call repaint on the JPanel. If I weren't familiar with these terms, I'd study up on them in the Oracle Swing and Graphics tutorials. YMMV.

Similar Threads

  1. Replies: 7
    Last Post: 04-18-2010, 08:09 AM
  2. Draw line
    By janes in forum Java 2D
    Replies: 6
    Last Post: 03-25-2010, 11:48 PM
  3. Draw more than one line on run time
    By aiman in forum Java Applets
    Replies: 3
    Last Post: 12-10-2009, 03:44 AM
  4. How to Draw line in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:08 AM
  5. How to draw a thick line
    By johnt in forum Java 2D
    Replies: 1
    Last Post: 05-31-2007, 05:27 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