Results 1 to 5 of 5
  1. #1
    amith is offline Member
    Join Date
    May 2008
    Posts
    24
    Rep Power
    0

    Default problem with threads

    import java.awt.*;
    import javax.swing.*;
    class d extends JComponent implements Runnable
    {
    Image r;
    Image g;
    int y=0;
    long floor=329;



    public void run()
    {
    r=new ImageIcon("red.png").getImage();
    g=new ImageIcon("blue.png").getImage();
    try
    {
    while(y!=floor)
    {
    y++;
    repaint();
    Thread.sleep(10);
    }
    }
    catch(Exception e)
    {
    }
    }

    public void paint(Graphics q)
    {
    q.drawImage(r,229,y,this);
    q.drawImage(g,229,y-32,this);

    }
    }


    class f
    {
    public static void main(String args[])
    {
    d v=new d();
    JFrame b=new JFrame("sdfdsf");
    b.getContentPane().add(v);
    b.setVisible(true);
    b.setSize(300,400);
    (new Thread(v)).start();
    }
    }
    in this code i had uploaded two image files iam using the thread so that using sleep method it comes slowly from y=0 and stops at point y=329 the first image should stop and it is stopping also and after that i just want to create another thread so that the existing image which had stopped at point y=329 should exist in the jframe and the new image should come from y=0 and should stop at point y=329-32 because my image height is of 32 , and it should lie on the old image and both the images should appear ,could u help me out of this problem

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

    Default

    What is your code doing that is incorrect? Does it show the two images but not move them or what?

  3. #3
    Join Date
    Jul 2008
    Posts
    2
    Rep Power
    0

    Default Hello all

    Hi this is prasad. i have joined recently and i just want to say hello to every one:D

  4. #4
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Hello Prasad,
    Welcome to our Forum... :)
    You are in a wrong place to say "HI"..

    Post it in a new thread...
    To finish sooner, take your own time....
    Nivedithaaaa

  5. #5
    Join Date
    Jul 2008
    Posts
    2
    Rep Power
    0

    Default thanks for the mail

    Hi Niveditha,

    Thanks for the information, i will post my hello message in a new thread.

    Bye,
    prasad.

Similar Threads

  1. Nqueens with threads
    By Zosden in forum Advanced Java
    Replies: 3
    Last Post: 06-20-2008, 09:29 PM
  2. Threads!
    By rameshraj in forum Advanced Java
    Replies: 1
    Last Post: 05-04-2008, 05:11 PM
  3. Using threads
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 11:25 AM
  4. Threads
    By one198 in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 07:15 PM
  5. Server n threads
    By ferosh in forum Networking
    Replies: 2
    Last Post: 04-28-2007, 11:42 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
  •