Results 1 to 5 of 5
  1. #1
    jumpgirl is offline Member
    Join Date
    Mar 2012
    Posts
    18
    Rep Power
    0

    Default 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.
    Last edited by jumpgirl; 04-12-2012 at 10:47 AM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default 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.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    jumpgirl is offline Member
    Join Date
    Mar 2012
    Posts
    18
    Rep Power
    0

    Default 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?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default 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.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    jumpgirl is offline Member
    Join Date
    Mar 2012
    Posts
    18
    Rep Power
    0

    Default 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.
    Java 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]);
    Last edited by jumpgirl; 04-14-2012 at 11:27 AM.

Similar Threads

  1. getting source name of an image
    By pietr0 in forum New To Java
    Replies: 7
    Last Post: 12-10-2011, 06:49 PM
  2. python source to java source converter?
    By conor147 in forum New To Java
    Replies: 0
    Last Post: 01-15-2010, 06:14 AM
  3. Replies: 1
    Last Post: 11-28-2008, 07:27 PM
  4. Replies: 0
    Last Post: 09-28-2008, 12:02 PM
  5. [SOLVED] Question about java.awt.image
    By byuu in forum AWT / Swing
    Replies: 18
    Last Post: 05-13-2008, 05:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •