1 Replies - 6553 Views - Last Post: 19 October 2010 - 10:46 AM Rate Topic: -----

#1 mitrapatel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-October 10

change images on button click

Posted 19 October 2010 - 09:36 AM

i am sending my attachment of the java file.
i have tried to put image with 3 buttons and 1 label.n in label image should be display. n when i click on button it changes the different images.but i didnt get success. even i dont get image in the frame. please tell me where i am wrong in the code n give me directions what should i do.

Attached File(s)

  • Attached File  image.txt (2.29K)
    Number of downloads: 428

Is This A Good Question/Topic? 0
  • +

Replies To: change images on button click

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2777
  • View blog
  • Posts: 11,758
  • Joined: 20-September 08

Re: change images on button click

Posted 19 October 2010 - 10:46 AM

You need something like the following:

    public class ButtonHandler implements ActionListener {
        public void actionPerformed(ActionEvent ae) {
            if (ae.getSource() == up) {
		k %= mypictures.length;
                ImageIcon icon1 = new ImageIcon(mypictures[k]);
                display.setIcon(icon1);
		k++;
                //repaint();
            }
        }
    }




Was This Post Helpful? 0
  • +
  • -

Page 1 of 1