hey i need help how do i pick a random image with a button???
--- Update ---
any one?
Printable View
hey i need help how do i pick a random image with a button???
--- Update ---
any one?
Welcome to Java Programming Forums.
What have you tried so far? And from where do you want to pick random image?
to be honest i dont know where to start. and the images are in the same folder as the program itself
There are two of the many possible strategies:
1. Rename your images with 0,1,2,3.....
Generate a random number, open the image against the random number while appening .jpg,.png etc
2. Create an array with the names of images, each cell holding one image name, generate a random number, open the array[randomnumber] image.
thank you that makes alot of scence one more question how do i open a JOptionPane with a JButton?
You know how to write click event for JButton, right? Asuming this, you can do whatever you want to do.
On click open the dialog.
thanks again man :)
No problem. If your problem has been solved, please mark this thread as Solved.