Results 1 to 2 of 2
- 01-30-2013, 02:33 AM #1
Member
- Join Date
- Jan 2013
- Posts
- 2
- Rep Power
- 0
Switching images based on a list or actionlistener
It was in the code, I am trying to display different images depending on which item is highlighted in a list. I will settle for a button used to collect the SelectedIndex(); but that did not work either. I want four different images to show up in the same place on different actions.
PHP Code:public void init() { if(r==i1) { //switch on selection img=this.getImage(this.getCodeBase(), "socks.jpg"); } else if(r==i2) { img=this.getImage(this.getCodeBase(), "shoes.jpg"); } else if(r==i3) { img=this.getImage(this.getCodeBase(), "pants.jpg"); } else if(r==i4) { img=this.getImage(this.getCodeBase(), "bike.jpg"); } } public void actionPerformed(ActionEvent e) { if(e.getSource()==btndisp) { lst1.add("Sucess!"); r=lst1.getSelectedItem(); lst1.add(r); //this simply won't display img=this.getImage(this.getCodeBase(), "socks.jpg"); lst1.add(r); } } public void paint(Graphics g) { g.drawImage(img,220,140,120,100,this); } public void update(Graphics gg) { paint(gg); } }Last edited by scottsational; 01-30-2013 at 04:44 AM.
-
Re: Switching images based on a list or actionlistener
How can you "bump" when you've neglected to ask a specific question?
Similar Threads
-
Trying to get a list that goes on to show images
By ciara in forum CLDC and MIDPReplies: 4Last Post: 12-05-2012, 06:26 PM -
Text matching based on a list/array ?
By jtzako in forum New To JavaReplies: 2Last Post: 08-31-2012, 09:47 AM -
populating a list box based on another without refreshing the page
By zahir in forum JavaServer Pages (JSP) and JSTLReplies: 8Last Post: 07-25-2011, 01:09 PM -
Import Images from XML & Replace Text Based on Regular Expression
By sherazam in forum Java SoftwareReplies: 0Last Post: 11-05-2010, 09:35 AM -
display images in a Web Application based on java/jsp
By mnsse in forum Advanced JavaReplies: 0Last Post: 03-25-2008, 12:45 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks