Closed Thread
Results 1 to 2 of 2

Thread: Animation

  1. #1
    p4ss is offline Newbie
    Join Date
    Mar 2010
    Posts
    1
    Rep Power
    0

    Post Animation

    hi guys

    Code:
    public void run() 
    {
                int x = 10; int y = 10;
                while (true) 
                {
         label.setText("DATA");           
    label.setBounds(x, y, 200, 10);
    
                    if(y == 250 && x != 250) x+=5;
                    else if(x == 250){
                        y -= 5;
                        if( y == 10) break;
                    }
                    else y +=5;
                    }
    }
    Based on the part of my program i want the animation of 'label" to adjust to window screen size..
    how can i do that..
    Last edited by ZekeDragon; 03-21-2010 at 01:26 AM. Reason: Please use [code] tags (the # button) when you post code.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    May 2009
    Location
    Belgium
    Posts
    1,879
    Rep Power
    24

    Re: Animation

    So instead of moving the JLabel you want to adjust the window size right? (By the way i didn't see the label move untill i added
    Code:
    try {
                    sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();  
                }
    Otherwise the label goes straight to it's final position from the start.

    Back to the window screen size issue:
    Code:
    SwingUtilities.getRoot(label).setSize(x,y);
    All you need

    The x,y loop is not infinite, yet the thread will keep running. It's probably better to do while(boolean) and then check inside if x and y is at it's final position, then set the boolean to false.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do you add an animation loop?
    By kaila2000 in forum Java Help
    Replies: 1
    Last Post: 05-03-2011, 06:33 AM
  2. DirectX Animation Help
    By chardoc89 in forum C and C++
    Replies: 0
    Last Post: 12-05-2010, 09:32 PM
  3. A ball animation
    By RobinW in forum C# Programming
    Replies: 0
    Last Post: 09-14-2010, 02:23 PM
  4. Animation with a textlabel
    By rubanus in forum Visual Basic Programming
    Replies: 2
    Last Post: 08-10-2007, 02:04 PM

Tags for this Thread

Bookmarks

Posting Permissions

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