943,648 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3423
  • Java RSS
Dec 21st, 2005
0

Random backgrounds

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
namit is offline Offline
44 posts
since Jun 2005
Dec 22nd, 2005
0

Re: Random backgrounds

read the filenames into a List, generate a sequence of random numbers, et voila.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Dec 22nd, 2005
0

Re: Random backgrounds

but have ya got any examples of this?
Reputation Points: 10
Solved Threads: 0
Light Poster
namit is offline Offline
44 posts
since Jun 2005
Dec 22nd, 2005
0

Re: Random backgrounds

You should be able to defer the code from what I wrote.
It's simple really.
Java Syntax (Toggle Plain Text)
  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
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Dec 22nd, 2005
0

Re: Random backgrounds

Use a Random object or something:

Random random = new Random(2);

int rotation = random.nextInt()+1;
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: I'm stuck
Next Thread in Java Forum Timeline: Sockets problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC