Random backgrounds

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2005
Posts: 44
Reputation: namit is an unknown quantity at this point 
Solved Threads: 0
namit namit is offline Offline
Light Poster

Random backgrounds

 
0
  #1
Dec 21st, 2005
i have a bunch of images

1.jpg, 2.jpg etc..

I have a class called banner and wondering how to get it to randomised threw the pics?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Random backgrounds

 
0
  #2
Dec 22nd, 2005
read the filenames into a List, generate a sequence of random numbers, et voila.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 44
Reputation: namit is an unknown quantity at this point 
Solved Threads: 0
namit namit is offline Offline
Light Poster

Re: Random backgrounds

 
0
  #3
Dec 22nd, 2005
but have ya got any examples of this?
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Random backgrounds

 
0
  #4
Dec 22nd, 2005
You should be able to defer the code from what I wrote.
It's simple really.
  1. List map = new ArrayList();
  2. // loop through files
  3. while (files.hasNext()) {
  4. map.add(files.next());
  5. }
or something like that.
That's of course not complete code but should serve as a starting point
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Random backgrounds

 
0
  #5
Dec 22nd, 2005
Use a Random object or something:

Random random = new Random(2);

int rotation = random.nextInt()+1;
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC