Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

image swap

  Asked By: Ashan    Date: Sep 12    Category: Java    Views: 869
  

I change a picture on a button click event like this :
//i have in the init method, the button and the two pictures definitions.
//in fact, the second picture is a pixelGrabbing of the first image with
more luminosity.

public void paint(Graphics g)
{
g.drawImage(img,10,30,this);
}
public void actionPerformed(ActionEvent e)
{
showStatus("ok");
getGraphics().drawImage(img2,10,30,this);
}

But, in this code, when i'm running my applet, i have to click two times in
order to see the new picture.

do i make an error somewhere?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Ivan Coleman     Answered On: Sep 12

Try to call repaint() after you draw the image.

 
Didn't find what you were looking for? Find more on image swap Or get search suggestion and latest updates.




Tagged: