Results 1 to 5 of 5
  1. #1
    T.Deepa is offline Member
    Join Date
    Jul 2011
    Location
    Chennai,India.
    Posts
    3
    Rep Power
    0

    Default Moving lines using timer

    Moving a bulk of lines usingtimer in java

  2. #2
    Zman3359's Avatar
    Zman3359 is offline Member
    Join Date
    Jan 2011
    Posts
    42
    Rep Power
    0

    Default

    In order to properly help you, we really need more specifics than that. Do you have any code yet? What exactly is it supposed to do? Things like that.

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

    Default

    Moving this thread to Java 2D ...

    db

  4. #4
    T.Deepa is offline Member
    Join Date
    Jul 2011
    Location
    Chennai,India.
    Posts
    3
    Rep Power
    0

    Default Moving lines

    I have a code.It display lines from al corner.
    I want to do simple animation in it.
    All lines are move slowly from all corner using timer or loops.
    Thanks




    import java.awt.Graphics;
    import java.awt.Point;
    import javax.swing.*;

    public class DrawPanel extends JPanel {
    Point p = new Point(1,21);
    public DrawPanel()
    {

    }

    public void paintComponent(Graphics g)
    {
    super.paintComponent(g);


    int width=getWidth();
    int height=getHeight();
    int h=height/2;
    int w=width/2;
    int h1=h/15;
    int w1=w/15;
    for(int i=1;i<=15;i++)
    {
    w1+=85;
    height-=64;
    g.drawLine(0,0,w1,height);
    }

    for(int i=1;i<=15;i++)
    {

    w1-=85;
    height+=64;
    g.drawLine(1280,962,w1,height);
    }
    for(int j=1;j<=15;j++)
    {

    width-=85;
    height-=64;
    g.drawLine(1280,0,width,height);
    }

    for(int j=1;j<=15;j++)
    {

    width+=85;
    height+=64;
    g.drawLine(0,962,width,height);
    }

    }



    }



    import java.awt.GraphicsConfiguration;
    import java.awt.Rectangle;
    import java.awt.Window;
    import java.awt.Window;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;


    public class DrawPanelT {
    public static void main(String args[])throws Exception
    {

    final DrawPanel pan=new DrawPanel();
    JFrame jf = new JFrame();
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jf.add(pan);
    jf.setSize(250, 250);
    jf.setVisible(true);
    }
    }

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    All lines are move slowly from all corner
    Do you mean you want the position that a line is displayed at changed over time?

    Then change the x,y used by the drawLine method

    Please edit your code and wrap it in code tags to preserve its formatting. See:http://www.java-forums.org/misc.php?do=bbcode#code

Similar Threads

  1. Timer And Timer Task
    By Ashish_jain in forum New To Java
    Replies: 3
    Last Post: 06-22-2011, 10:41 AM
  2. Cannot Add new Lines
    By capjoel in forum New To Java
    Replies: 3
    Last Post: 04-01-2011, 07:33 PM
  3. What do these lines mean?
    By coding in forum New To Java
    Replies: 5
    Last Post: 02-02-2011, 04:01 AM
  4. Stopping a Timer from Inside the timer
    By krishnan in forum Java Applets
    Replies: 2
    Last Post: 10-05-2010, 12:15 AM
  5. Replies: 0
    Last Post: 04-04-2008, 03:46 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
  •