GeeCON Prague 2014*
The moose likes Applets and the fly likes hello  string beind displayed again and again as i click on maximize button(applet)why is that so?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Applets
Bookmark "hello  string beind displayed again and again as i click on maximize button(applet)why is that so??" Watch "hello  string beind displayed again and again as i click on maximize button(applet)why is that so??" New topic
Author

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

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1055

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


http://www.lifesbizzare.blogspot.com || OCJP:81%
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
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.


Ping & DNS - my free Android networking tools app
 
GeeCON Prague 2014
 
subject: hello string beind displayed again and again as i click on maximize button(applet)why is that so??