Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing data into an applet

Status
Not open for further replies.

johnnyv

Programmer
Jul 13, 2001
216
CA
Hello I am new to java so bare with me

I hav created a java applet to display images stored in a folder.

currently the applet displays all of the images

I would like to be able to have the applet display only the images that I choose. I would like to be able to pass in the name of the images to be displayed

can this be done?

How do you pass information ie names of files into a java applet?

thanks
 
Easy...
beetwin <applet></applet> tags insert tag that looks like <param name=&quot;filename&quot; value=&quot;blablabla.gif&quot;>. Applet have function: String getParameter ( String ); so to get &quot;blablabla.gif&quot; simply write something like this: getParameter ( &quot;filename&quot; ); This function will return String with value &quot;blablabla.gif&quot; or null if no such parameter was found! For example if I will write getParameter ( &quot;aaa&quot; ) then I will have null on return because there is no such parameter in HTML file ( no string like <param name=&quot;aaa&quot; value=&quot;&quot;>. Thats all...
 
Thanks for your reply

let me modify the orginal question abit if I could

my web page will have 3 different buttons on it and 3 seperate folders containing images.
Depending on the button pressed I would like to have the applet display the images in the corresponding folder

ie if button 1 is pressed display the images in folder 1 only, if button 2 is pressed display the images in folder 2 etc

So I would like to be able to pass in the image names and path depending on the button pressed

Can I do this??

thanks again for the responce
 
Write a public method in your applet with image_name and path parameters and call this method (from JavaScript) when a button has changed.
I posted some example about a year ago :). If you need more specific, try to find it (key words: from data to java applet).

Otto
 
Excellent thanks I will find your example
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top