Set Method's in java
In this example we are going to use set method. To call the set method(), In this we are using Graphics class and Applet class.
Example
//Display method
import java.awt.*;
import java.applet.*;
/*
<applet code="Method" width=300 height=200>
</applet>
*/
public class Method extends Applet{
String msg;
public void init(){
setBackground(Color.red);
setForeground(Color.green);
msg="init method ";
}
public void start(){
msg +="start method ";
}
public void paint(Graphics g){
msg+="paint method";
g.drawString(msg,10,30);
}
}
Output of Example: