• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hello string beind displayed again and again as i click on maximize button(applet)why is that so??

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.applet.Applet;
import java.awt.*;
/*<APPLET code=applet1.class width=200 height=200>

</applet>*/
public class applet1 extends Applet
{
public TextField text1;
Button b1;

public void init()
{
setBackground(Color.white);
text1=new TextField(20);
add(text1);
text1.setText("Hello from java ");
b1=new Button("Click Here!");
add(b1);

}
public void paint(Graphics g)
{
g.drawString("Hello from java",60,100);
System.out.println("Hello");
}
public void stop()
{

}
public void destroy()
{

}
}

Hello is dislayed again when i click on maximise button ,Why is that happening
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The paint method may be called multiple times - every time the JVM thinks that part of the GUI need to be redrawn, even when you'd think that there's no need for it. Your code should not make any assumptions about how often that will happen.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic