getting Image source in java question
Hi, I'm trying to make a photo gallery in java. Is it possible to get the url or the source of the image when the image is clicked?
The photos extend JButton that is why they are clickable.
If possible can someone give me a hint or an idea on how to make a photo gallery in java? The url is stored in the database. I'm already able to display up to 6 photos but I have no idea how to change the photos after clicking the page number button.
Thank you in advance.
Re: getting Image source in java question
Have the photos button hold the details you want.
There's no reason it couldn't hold an id referring to the relevant row in the database...or even simply hold the URL, so you don't have to go to the db to retrieve that value.
Re: getting Image source in java question
thank you for your answer.
I don't understand how to have the photos hold the details. Can you explain further?
Re: getting Image source in java question
You said it extends JButton.
So you have already changed how the button works (otherwise why extend it).
Just add whatever data you need to that class you've created.
Re: getting Image source in java question
Thank you! it already worked.
I have another question. Since it is a photo gallery, I need to have page numbers but I don't have any idea how to change the images after clicking a certain page. Can you give me an idea on how to do it?
I stored the images in an array. Thanks in advance.
This a part of my code.
Code:
public void placeImages(String url){
thumbs[ctr] = new CustomButton(url);
if(ctr == 0){
thumbs[ctr].setBounds(30, 90,194,155);
thumbs[ctr].addActionListener(clicked0);
src0 = url;
}.......................so on
add(thumbs[ctr]);