Some important methos in Applets
By Ramakrishna on Aug 9, 2008 in Applets Tutorial
Applet methods:
public void init ()
public void start ()
public void stop ()
public void destroy ()
public void paint (Graphics)
Also:
public void repaint()
public void update (Graphics)
public void showStatus(String)
public String getParameter(String)
repaint( ) method:
Call repaint( ) when you have changed something and want your changes to show up on the screen
repaint( ) is a request–it might not happen
When you call repaint( ), Java schedules a call to update(Graphics g)
update( ) method:
When you call repaint( ), Java schedules a call to update(Graphics g)
Here’s what update does:
public void update(Graphics g) { // Fills applet with background color, then paint(g);}
Sample Graphics methods:
–>A Graphics is something you can paint on
–>g.drawString(“Hello”, 20, 20);
–>g.drawRect(x, y, width, height);
–>g.fillRect(x, y, width, height);
–>g.drawOval(x, y, width, height);
–>g.fillOval(x, y, width, height);
–>g.setColor(Color.red);
