hi guys
Based on the part of my program i want the animation of 'label" to adjust to window screen size..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; } }
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.
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
Otherwise the label goes straight to it's final position from the start.Code:try { sleep(10); } catch (InterruptedException e) { e.printStackTrace(); }
Back to the window screen size issue:
All you needCode:SwingUtilities.getRoot(label).setSize(x,y);
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks