hello, i added some images to jpanel, with some animation.
i put some images in a folder, and i m display/moving them on jpanel simultaneously.
my question is can i add images dynamically??
i mean what i want is, i want to add a button on that panel, and when i click on that button, one more image (randomly) should added to my jpanel from that folder.
how can i do this??
Joined: Jun 09, 2003
the code to add the image is identical to
how you'd add it when the frame first opens.
because the frame is now visible, after
adding it you need to have these lines
panel.add(image);//however you add it
Joined: Aug 20, 2011
but how even i add add those images on button click one by one, i mean how i get images randomly from my image folder??
above is what i am doing right now.
Joined: Oct 21, 2000
you need to use Math.random()
check the API and tutorials