import java.awt.* ;
public class CanvasDemo
{
public static void main(String args[])
{
Frame f = new Frame() ;
f.setLayout(new FlowLayout());
MyCanvas c = new MyCanvas();
c.setBackground(Color.red);
c.setSize(100,100);
f.add(c) ;
f.setSize(300,300);
f.setVisible(true);
}
}
class MyCanvas extends Canvas
{
public void paint(Graphics g)
{
setBackground(Color.green) ;
g.setColor(Color.red) ;
g.drawLine(0,0,100,100);
}
}
Comments
Post a Comment