g.drawBytes(byte[ ] data, int offset, int length, int x, int y)
|
g.drawChars(char[ ] data, int offset, int length, int x, int y)
|
g.drawString(String str, int x, int y)
|
g.drawLine( int x1, int y1, int x2, int y2)
|
g.drawRect( int x1, int y2, int width, int height)
g.fillRect( int x1, int y2, int width, int height)
|
g.drawRoundRect( int x1, int y2, int width, int height, int width1, int height1)
g.fillRoundRect( int x1, int y2, int width, int height, int width1, int height1)
|
g.drawOval( int x1, int y2, int width, int height)
g.fillOval( int x1, int y2, int width, int height)
|
g.draw3DRect( int x1, int y2, int width, int height, true/false)
|
g.drawPolygon( int xs[ ], int ys [ ] )
g.fillPolygon( int xs[ ], int ys [ ] )
|
g.drawArc(int x1, int y1, int width, int height, angle1, angle2)
g.fillArc(int x1, int y1, int width, int height, angle1, angle2)
|
g.drawImage(image img, int x, int y, int width, int height, imageObserver)
|
import java.awt.*;
import java.applet.Applet;
public classmovingBall extends Applet implements Runnable {
Thread mythread = null;
int position =0;
public void start( )
{
mythread =new mythread (this); // this refers to current object
mythread.start( );
}
public void run( )
{
while(true)
{
for(position=o; position {
repaint();
try{ mythread.sleep(100); }
catch(InterruptedException e) { };
}
}
}
public void stop( )
{
mythread.stop( );
mythread=null;
}
public void paint(graphics g)
{
g.setColor(Color.gray);
g.fillOval(position,50,30,30);
g.setColor(Color.black);
g.fillOval(position+6,58,5,5);
g.drawLine(position,58,10,12);
}
}